Hi everyone,
I have a problem trying to calibrate two webcams on a vertical setup for depth estimation.
Opencv version : 4.7.0
The code is globally
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, error1)
flags = (cv2.CALIB_FIX_ASPECT_RATIO
+ cv2.CALIB_ZERO_TANGENT_DIST
+ cv2.CALIB_USE_INTRINSIC_GUESS
+ cv2.CALIB_RATIONAL_MODEL
+ cv2.CALIB_FIX_K3 + cv2.CALIB_FIX_K4 + cv2.CALIB_FIX_K5)
retL, mtxL, distL, rvecsL, tvecsL = cv2.calibrateCamera(obj_ptsL, img_ptsL, (w1,h1), None, None)
retR, mtxR, distR, rvecsR, tvecsR = cv2.calibrateCamera(obj_ptsR,img_ptsR,(w2,h2),None,None)
retS, mtxL, distL, mtxR, distR, Rot, Trns, Emat, Fmat = cv2.stereoCalibrate(obj_pts, img_ptsL, img_ptsR, mtxL, distL, mtxR, distR, (w1, h1), criteria_stereo, flags)
rect_l, rect_r, proj_mat_l, proj_mat_r, Q, roiL, roiR = cv2.stereoRectify(mtxL, distL, mtxR, distR, (w1,h1), Rot, Trns, flags = cv2.CALIB_ZERO_DISPARITY, alpha = 1, newImageSize = (0,0))
Left_Stereo_Map = cv2.initUndistortRectifyMap(mtxL, distL, rect_l, proj_mat_l, new_shape, cv2.CV_16SC2)
Right_Stereo_Map= cv2.initUndistortRectifyMap(mtxR, distR, rect_r, proj_mat_r, new_shape, cv2.CV_16SC2)
I tried different sizes and alpha for stereorectify and none works but it seems that the result image is shifted on the top out of the size of the image
the only work around i found is to change the cy values on projection matrix manually before initUndistortRectify. but don’t know how it affects my disparity map
proj_mat_l[1,2] = 0
proj_mat_r[1,2] = 0
Does any one knows where is the problem ?