Ask Your Question
0

Compute stereo remapped points without applying cv::remap to whole image.

asked 2016-06-11 00:08:56 -0600

Worker gravatar image

I can compute the same feature's coordinate in left and right stereo image ,please suggest a faster way to compute these points in location in stereo calibrated image without applying cv::remap to whole image.

The initUndistortRectifyMap function in opencv results in maap in x and y direction that contains the coordinates of the undistorted pixel it computes these maps based on intrinsic camera matrix ,distortion matrix and rotation matrix.

initUndistortRectifyMap(cam1,dst1,R1,P1, imageSize, CV_16SC2, map1x,map1y);

cam1 (intrinsic camera matrix) dst1 (distortion coefficients) R1 (Rotation Matrix) map1x (new map of size of the image to denote where the shifted x coordinate lies in undistorted image) map2x ((new map of size of the image to denote where the shifted y coordinate lies in undistorted image) So if new the image coordinates in distorted image (xdistort,ydistort) the undistorted can be computed using

x_undistort = map1x.at<short>(ydistort,xdistort);
y_undistort = map2x.at<short>(ydistort,xdistort);

I checked the corresponding points in undistorted image they donot result in the same point. I checked the value of map1x at (0,0) and it contains negative value and when I click on console to find the coordinate value it gives the corresponding result from (0:im_width,0:imheight) . Is there any normalization procedure ? How to compute points directly without processing the whole image .

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-06-11 12:16:05 -0600

Tetragramm gravatar image

Use the undistortPoints function. It should do everything you're asking for.

I'm not sure how exactly it works, but you can check the code if you want to know.

edit flag offensive delete link more

Comments

Hi, thanks for answering, undistortPoints corresponds to removal of distortion but I have stereo images (left and right) on which I need to apply stereo rectification for the computation of depth.So undistortPoints will not solve the issue.

Worker gravatar imageWorker ( 2016-06-11 18:25:07 -0600 )edit

It allows you to pass in R1 and P1, just like initUndistortRectifyMap. What's missing?

Tetragramm gravatar imageTetragramm ( 2016-06-11 22:47:05 -0600 )edit

For a stereo pair the images are stereo rectified so that the same point in left and right image lies in the same row for both images. I have tested the values obtained from undistortPoints function and they don't match with the values obtained from remap function.

Worker gravatar imageWorker ( 2016-06-13 08:43:47 -0600 )edit

Well, I'm not sure why that's not working I suggest getting the remap as a CV_32FC1 instead of CV_16UC2. The first map is the new X, and the second is the new Y. There are instructions somewhere on how to use the CV-16U version, but it's much more complicated. This is not as nice as undistortPoints would be, but should work.

Tetragramm gravatar imageTetragramm ( 2016-06-13 17:20:09 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-06-11 00:08:56 -0600

Seen: 1,586 times

Last updated: Jun 11 '16