I wish to convert a MATLAB stereoParameters structure to intrinsics and extrinsics matrices to use in OpenCV's stereoRectify.
If I understood http://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html and http://mathworks.com/help/vision/ref/stereoparameters-class.html , stereoParameters.CameraParameters1 and stereoParameters.CameraParameters2 store the intrinsic matrices and the other members of stereoParameters the extrinsic ones.
I think I got this mapping
Intrinsics:
- cameraMatrix1 = stereoParameters.CameraParameters1.IntrinsicMatrix'
- cameraMatrix2 = stereoParameters.CameraParameters2.IntrinsicMatrix'
- distCoeffs1 = [stereoParameters.CameraParameters1.RadialDistortion(1:2), stereoParameters.CameraParameters1.TangentialDistortion, stereoParameters.CameraParameters1.RadialDistortion(3)]
- distCoeffs2 = [stereoParameters.CameraParameters2.RadialDistortion(1:2), stereoParameters.CameraParameters2.TangentialDistortion, stereoParameters.CameraParameters2.RadialDistortion(3)]
Extrinsics:
- R = stereoParameters.RotationOfCamera2'
- T = stereoParameters.TranslationOfCamera2'
Is that correct, so far?
Still, I can't see how to get
- R1 (3x3)
- R2 (3x3)
- P1 (3x4)
- P2 (3x4)
- Q (4x4)
matrices from the rest of stereoParameters.
Is there an existing converter I can use, and if not, what are the formulas?