cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mizan123
Contributor
Contributor
209 Views
Registered: ‎10-30-2018

No valid output at Undistort image using hls vision library

I have implemented the InitUndistortRectifyMapInverse and remap function of the vision library for lens distortion correction. I needed a lens correcting IP which capable of processing real-time stream data (of course there would be latency). I am getting no valid data at the output. I have some doubts about the format of camera_mat, dist_mat, ir matrix. Especially about ir variable, I just defined it as a rotation matrix. Have I done something wrong? 

 

#include "xf_stereo_pipeline_config.h"
extern "C" {

void sp(hls::stream< ap_axiu<24,1,1,1> >& input_image, hls::stream< ap_axiu<24,1,1,1> >& output_image) {
// clang-format off
#pragma HLS INTERFACE axis port=input_image
#pragma HLS INTERFACE axis port=output_image
#pragma HLS INTERFACE ap_ctrl_none port=return
// clang-format on

ap_fixed<32, 12> camera_mat[]= {534.341449, 0., 339.155271, 0., 534.684263, 233.843597, 0., 0., 1.};
ap_fixed<32, 12> dist_mat[]={ -0.288321, 0.054108, 0.001735, -0.000261, 0.204109};
ap_fixed<32, 12> ir_mat[]={ 1. , 0.,0.,0.,1.,0.,0.,0.,1. };

int _cm_size = 9, _dc_size = 5;
int rows= 1080;
int cols=1920;

xf::cv::Mat<XF_8UC3, XF_HEIGHT, XF_WIDTH, XF_NPPC1> input_mat(rows, cols);
xf::cv::Mat<XF_32FC1, XF_HEIGHT, XF_WIDTH, XF_NPPC1> mapxMat(rows, cols);
xf::cv::Mat<XF_32FC1, XF_HEIGHT, XF_WIDTH, XF_NPPC1> mapyMat(rows, cols);
xf::cv::Mat<XF_8UC3, XF_HEIGHT, XF_WIDTH, XF_NPPC1> remappedMat(rows, cols);

// clang-format off
#pragma HLS DATAFLOW
// clang-format on

xf::cv::AXIvideo2xfMat(input_image, input_mat);
xf::cv::InitUndistortRectifyMapInverse<XF_CAMERA_MATRIX_SIZE, XF_DIST_COEFF_SIZE, XF_32FC1, XF_HEIGHT, XF_WIDTH,
XF_NPPC1>(camera_mat, dist_mat, ir_mat, mapxMat, mapyMat, _cm_size, _dc_size);
xf::cv::remap<XF_REMAP_BUFSIZE, XF_INTERPOLATION_BILINEAR, XF_8UC3, XF_32FC1, XF_8UC3, XF_HEIGHT, XF_WIDTH,
XF_NPPC1, XF_USE_URAM>(input_mat, remappedMat, mapxMat, mapyMat);
xf::cv::xfMat2AXIvideo(remappedMat, output_image);
}
}

 

Associated Header file

 

#include "hls_stream.h"
#include "common/xf_common.hpp"
#include "common/xf_utility.hpp"
#include "imgproc/xf_stereo_pipeline.hpp"
#include "imgproc/xf_remap.hpp"
#include "imgproc/xf_stereolbm.hpp"
#include "xf_config_params.h"
#include "ap_axi_sdata.h"
#include "common/xf_infra.hpp"

/* config width and height */
#define XF_HEIGHT 1080
#define XF_WIDTH 1920

#define XF_CAMERA_MATRIX_SIZE 9
#define XF_DIST_COEFF_SIZE 5

#endif // _XF_STEREO_PIPELINE_CONFIG_H_

 

0 Kudos
0 Replies