Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can I convert cordinates from rectified stereo to original coordinates in opencv?

I am using this code to rectify stereo pair of images:

stereoRectify(cm, Mat(), cm, Mat(),imageSize,
    RT_d,tt,R1,R2,P1,P2,Q,CALIB_ZERO_DISPARITY,
    0.9, imageSize, &validROI[0], &validROI[1]);

initUndistortRectifyMap(cm, Mat(), R1, P1, imageSize, CV_16SC2, rmap[0][0], rmap[0][1]);
initUndistortRectifyMap(cm, Mat(), R2, P2, imageSize, CV_16SC2, rmap[1][0], rmap[1][1]);
remap(v1.img, rimg1, rmap[0][0], rmap[0][1], INTER_LINEAR);
remap(v2.img, rimg2, rmap[1][0], rmap[1][1], INTER_LINEAR);

Rectification works successfully.

Now I need to match each pixel (x,y) in rectified image rimg1 to initial pixel (x0,y0) in v1.img. How can I do it? Where can I get formulae, how to use P1 and R1? Thanx!