Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problems with rectified pictures for stereo vision

I m trying to do stereo matching but it doesnt work well until now. I determined the "tvecs" and "rvecs" for each camera. So i can use these relationships to get the translation vector and rotation matrix :

R = Rright.Rleft.T and T = Tright - R.Tleft
with the meaned values of Tleft , Tright, Rright and Rleft

But i have a problem during the rectification step... The scale of rectified pictures have changed...and i dont know how to fix it...

A piece of my code for the left picture :

#i obtained the new camera matrix for the rectification 
C1new = cv2.getOptimalNewCameraMatrix(C1,dist1,(2048,2048),alpha=1)[0] #with C1 and dist1 respectively the #camera matrix and the distorsion values 

#and i obtained the map and i remap... 
left_maps = cv2.initUndistortRectifyMap(C1, dist1, R1, C1new, (2048, 2048), cv2.CV_32FC2) 
a = left_maps[0] 
left_img_remap = cv2.remap(left_stereo_image2, a[:,:,0], a[:,:,1], cv2.INTER_CUBIC)

And i got that... :

image description

To improve my results i tried to concatenate empty arrays to plot all the picture but when i do that and modify the size in "getOptimalNewCameraMatrix" and "initUndistortRectifyMap", i got :

image description

This time i got all the pictures but the scale between them is not good...so i cant determine disparity... Thanks for your help ;)