In stereo imaging, images are rectified before disparity calculation. Points in disparity map corresponds to points in the rectified image. If I hope to know corresponding points in unrectified image, so I need to apply inverse operation of rectification to disparity map. Am I right? Is there any such function in OpenCV?
1 Answers
0
votes
I am not aware of any function in opencv which directly gives you this result. But this is the hack I used.I guess you can use the map function obtained in stereoRectify function.Something like this. Though code is self explanatory, but if you need some help feel free to ask.
`
for(int row = 0; row < noRows; row++)
{
for(int col = 0; col < noCols; col++)
{
float disp = imgDisparity.at<float>(row, col);
if(disp > 0) // valid disparity only
{
Vec2s v1, v2;
int x1, x2, y1, y2; // corresponding coordinates
v1 = mapL.at<Vec2s>(row, col);
v2 = mapR.at<Vec2s>(row, col - (int)disp);
x1 = v1[0];
x2 = v2[0];
y1 = v1[1];
y2 = v2[1];
}
}
}
`