HLS InitUndistortRectifyMap

hls::InitUndistortRectifyMap


Synopsis


1. InitUndistortRectifyMap:
template<typename CMT, typename RT, typename DT, int ROWS, int COLS, int MAP1_T, int MAP2_T, int N>
void hls::InitUndistortRectifyMap( hls::Window<3, 3, CMT> cameraMatrix,
                                   DT (&distCoeffs)[N],
                                   hls::Window<3, 3, RT> R,
                                   hls::Window<3, 3, CMT> newcameraMatrix,
                                   hls::Mat<ROWS, COLS, MAP1_T>& map1,
                                   hls::Mat<ROWS, COLS, MAP2_T>& map2 );
2. InitUndistortRectifyMatoInverse:
template<typename CMT, typename ICMT, typename DT, int ROWS, int COLS, int MAP1_T, int MAP2_T, int N>
void hls::InitUndistortRectifyMapInverse( hls::Window<3, 3, CMT> cameraMatrix,
                                          DT (&distCoeffs)[N],
                                          hls::Window<3, 3, ICMT> ir,
                                          hls::Mat<ROWS, COLS, MAP1_T>& map1,
                                          hls::Mat<ROWS, COLS, MAP2_T>& map2 );

Parameters

  • cameraMatrix – the input matrix representing the camera in the old coordinate system.
  • DT – the input distortion coefficients (generally 4, 5, or 8 distortino coefficients are provided).
  • R – the input rotation matrix.
  • newCameraMatrix – the input matrix representing the camera in the new coordinate system.
  • ir – the input transformation matrix, equal to Invert(newCameraMatrix*R).
  • map1, map2 – images representing the remapping.

Description


These function generates map1 and map2, based on a set of parameters, where map1 and map2 are suitable for hls::Remap(). That is, for each pixel in (u, v) in the destination (corrected and rectified) image, the function computes the corresponding coordinates in the source image (the original image from camera). The following process is applied:
InitUndistortRectifyMap5.png
In general, InitUndistortRectifyMapInverse() is preferred for synthesis, since the per-frame processing to compute ir is performed outside of the synthesized logic. Note that the various parameters may be floating poing or fixed point. If fixed point inputs are used, then internal coordinate transformations are done with at least the precision given by ICMT.
As the coordinate transformations implemented in this function can be hardware resource intensive, it may be preferrable to compute the results of this function offline and store map1 and map2 in external memory if the input parameters are fixed and sufficient external memory bandwidth is available.

Limitation


Map1 and Map2 are only supported as HLS_16SC2. camaraMatrix and newCameraMatrix are 'normalized', have the same form:
InitUndistortRectifyMap3.pngInitUndistortRectifyMap4.png
R and ir are also 'normalized' with the form:
InitUndistortRectifyMap2.png

OpenCV reference


cv::initUndistortRectifyMap