Ask Your Question
0

Remap a single point unsing maps from initUndistortRectifyMap().

asked 2018-01-22 10:43:33 -0600

Soarez gravatar image

updated 2018-01-22 10:45:06 -0600

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.

image description

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

edit retag flag offensive close merge delete

Comments

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?

cmdkeen gravatar imagecmdkeen ( 2018-03-14 09:57:39 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2020-09-28 21:29:06 -0600

EwingKang gravatar image

@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.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-01-22 10:43:33 -0600

Seen: 11,546 times

Last updated: Jan 22 '18