hello i extracted the following stereo camera parameters from matlab , i dont know to to make it in opencv format
Camera 1 Intrinsics
Focal length (pixels): [ 1062.8663 +/- 1.7473 1062.1262 +/- 1.7367 ]
Principal point (pixels):[ 958.0507 +/- 0.3169 545.8194 +/- 0.3959 ]
Radial distortion: [ 0.0213 +/- 0.0003 -0.0232 +/- 0.0003 ]
Camera 2 Intrinsics
Focal length (pixels): [ 1057.7849 +/- 1.7440 1056.6368 +/- 1.7317 ]
Principal point (pixels):[ 968.4359 +/- 0.3319 545.3497 +/- 0.3909 ]
Radial distortion: [ 0.0222 +/- 0.0003 -0.0245 +/- 0.0003 ]
Position And Orientation of Camera 2 Relative to Camera 1
Rotation of camera 2: [ -0.0019 +/- 0.0001 0.0093 +/- 0.0001 0.0012 +/- 0.0000 ]
Translation of camera 2 (millimeters):[ -59.6460 +/- 0.0055 0.1108 +/- 0.0041 0.4209 +/- 0.0115 ]
i used it as it is with the following but the rectification became really bad
Compute rectification maps
R1, R2, P1, P2, Q, _, _ = cv2.stereoRectify(
camera_matrix1, dist_coeff1,
camera_matrix2, dist_coeff2,
(left_img.shape[1], left_img.shape[0]),
R, T,
flags=cv2.CALIB_ZERO_DISPARITY, alpha=-1
)
Compute rectification maps
map1_left, map2_left = cv2.initUndistortRectifyMap(
camera_matrix1, dist_coeff1, R1, P1,
(left_img.shape[1], left_img.shape[0]), cv2.CV_16SC2
)
map1_right, map2_right = cv2.initUndistortRectifyMap(
camera_matrix2, dist_coeff2, R2, P2,
(right_img.shape[1], right_img.shape[0]), cv2.CV_16SC2
)
Remap the images using the rectification maps
left_img_rectified = cv2.remap(left_img, map1_left, map2_left, cv2.INTER_LINEAR)
right_img_rectified = cv2.remap(right_img, map1_right, map2_right, cv2.INTER_LINEAR)