# Remap a single point unsing maps from initUndistortRectifyMap().

Hi, im tring to remap a set of points. Im using fisheye lens and calibrating the camera with opencv fisheye model, and it goes very nice. at the end of the calibration i do fisheye::initUndistortRectifyMap(), to get the map1 and map2. After this is test correction of the image with remap(distorted_img, undist_img, map1, map2, linear); and it works fine. Yet when im tring to remap a single point using :

   y=map2.at<float>(distorted[i].y,distorted[i].x);
x=map1.at<float>(distorted[i].y,distorted[i].x);


i dont get the same as the remap function.

[For initUndistortRectifyMap] im using now CV_32FC1 and i get 2 maps with x, y coordinates, but when i use CV_16UC2 i get map1 with x,y info equal to the 2 maps from 32FC1 type and i dont understand the output on map2 (from CV_16UC2 ).

i give you some images to help.

original image | undistorted image (using remap) and works with both types (CV_32FC1 CV_16UC2)

edit retag close merge delete

I am having similar issues, my guess is that the maps generated with initUndistortRectifyMap() are only used for inverse mapping. Did you make any progress or could you solve this issue by now?

( 2018-03-14 09:57:39 -0500 )edit

Sort by » oldest newest most voted

@cmdkeen is correct regarding the inverse mapping. According to the documentation of initUndistortRectifyMap(), I qoute:

The function actually builds the maps for the inverse mapping algorithm that is used by remap. That is, for each pixel (u,v) in the destination (corrected and rectified) image, the function computes the corresponding coordinates in the source image (that is, in the original image from camera). The following process is applied: ...

Essentially it's a f(undistorted) = distorted map (source).

x_distorted = map1.at<float>(y_rect,x_rect);
y_distorted = map2.at<float>(y_rect,x_rect);


For single coordinate conversion, if you don't care about the speed, you may want to try undistortPoints() function. Or you can always pre-built your own map with the function and stores it for later usage.

more

Official site

GitHub

Wiki

Documentation