computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, that makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. On input the function takes the matrices computed by cvStereoCalibrate and on output it gives 2 rotation matrices and also 2 projection matrices in the new coordinates. The function is normally called after cvStereoCalibrate that computes both camera matrices, the distortion coefficients, R and T

C# | Visual Basic | Visual C++ |
public static void cvStereoRectify( IntPtr cameraMatrix1, IntPtr cameraMatrix2, IntPtr distCoeffs1, IntPtr distCoeffs2, Size imageSize, IntPtr R, IntPtr T, IntPtr R1, IntPtr R2, IntPtr P1, IntPtr P2, IntPtr Q, STEREO_RECTIFY_TYPE flags )
Public Shared Sub cvStereoRectify ( _ cameraMatrix1 As IntPtr, _ cameraMatrix2 As IntPtr, _ distCoeffs1 As IntPtr, _ distCoeffs2 As IntPtr, _ imageSize As Size, _ R As IntPtr, _ T As IntPtr, _ R1 As IntPtr, _ R2 As IntPtr, _ P1 As IntPtr, _ P2 As IntPtr, _ Q As IntPtr, _ flags As STEREO_RECTIFY_TYPE _ )

- cameraMatrix1 (IntPtr)
- The camera matrices [fx_k 0 cx_k; 0 fy_k cy_k; 0 0 1]
- cameraMatrix2 (IntPtr)
- The camera matrices [fx_k 0 cx_k; 0 fy_k cy_k; 0 0 1]
- distCoeffs1 (IntPtr)
- The vectors of distortion coefficients for first camera, 4x1, 1x4, 5x1 or 1x5
- distCoeffs2 (IntPtr)
- The vectors of distortion coefficients for second camera, 4x1, 1x4, 5x1 or 1x5
- imageSize (Size)
- Size of the image used for stereo calibration
- R (IntPtr)
- The rotation matrix between the 1st and the 2nd cameras' coordinate systems
- T (IntPtr)
- The translation vector between the cameras' coordinate systems
- R1 (IntPtr)
- 3x3 Rectification transforms (rotation matrices) for the first camera
- R2 (IntPtr)
- 3x3 Rectification transforms (rotation matrices) for the second camera
- P1 (IntPtr)
- 3x4 Projection matrices in the new (rectified) coordinate systems
- P2 (IntPtr)
- 3x4 Projection matrices in the new (rectified) coordinate systems
- Q (IntPtr)
- The optional output disparity-to-depth mapping matrix, 4x4, see cvReprojectImageTo3D.
- flags (STEREO_RECTIFY_TYPE)
- The operation flags