def compute_rectification(ms_rig):
"""
:type ms_rig: MultiStereoRig
:param ms_rig:
:return:
"""
for stereo_rig in ms_rig.rigs:
im_size = stereo_rig.cameras[0].intrinsics.resolution
rotation1, rotation2, pose1, pose2, Q = \
cv2.stereoRectify(cameraMatrix1=stereo_rig.cameras[0].intrinsics.intrinsic_mat,
distCoeffs1=stereo_rig.cameras[0].intrinsics.distortion_coeffs,
cameraMatrix2=stereo_rig.cameras[1].intrinsics.intrinsic_mat,
distCoeffs2=stereo_rig.cameras[1].intrinsics.distortion_coeffs,
imageSize=(im_size[1], im_size[0]),
R=stereo_rig.cameras[1].extrinsics.rotation,
T=stereo_rig.cameras[1].extrinsics.translation,
flags=cv2.CALIB_ZERO_DISPARITY)[0:5]
stereo_rig.cameras[0].stereo_rotation = rotation1
stereo_rig.cameras[1].stereo_rotation = rotation2
stereo_rig.cameras[0].stereo_pose = pose1
stereo_rig.cameras[1].stereo_pose = pose2
stereo_rig.extrinsics.inv_rotation = np.linalg.inv(stereo_rig.extrinsics.rotation)
stereo_rig.Q = Q
stereo_rig.f = Q[2, 3]
stereo_rig.inv_baseline = Q[3, 2]
stereo_rig.ox = Q[0, 3]
stereo_rig.oy = Q[1, 3]
评论列表
文章目录