Skip to content

stereoRectify

stereofunctionOpenCV 5.0.0
import { stereoRectify } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTScameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2
FUNCTIONstereoRectify
RETURN TYPEstereoRectifyResult
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Computes rectification transforms for each head of a calibrated stereo camera.

stereoRectify(cameraMatrix1: Mat, distCoeffs1: Mat, cameraMatrix2: Mat, distCoeffs2: Mat, imageSize: Size, R: Mat, T: Mat, R1: Mat, R2: Mat, P1: Mat, P2: Mat, Q: Mat, flags: number, alpha: number, newImageSize: Size): stereoRectifyResult;
4 available overloads
stereoRectify(cameraMatrix1: Mat, distCoeffs1: Mat, cameraMatrix2: Mat, distCoeffs2: Mat, imageSize: Size, R: Mat, T: Mat, R1: Mat, R2: Mat, P1: Mat, P2: Mat, Q: Mat): stereoRectifyResult;
stereoRectify(cameraMatrix1: Mat, distCoeffs1: Mat, cameraMatrix2: Mat, distCoeffs2: Mat, imageSize: Size, R: Mat, T: Mat, R1: Mat, R2: Mat, P1: Mat, P2: Mat, Q: Mat, flags: number): stereoRectifyResult;
stereoRectify(cameraMatrix1: Mat, distCoeffs1: Mat, cameraMatrix2: Mat, distCoeffs2: Mat, imageSize: Size, R: Mat, T: Mat, R1: Mat, R2: Mat, P1: Mat, P2: Mat, Q: Mat, flags: number, alpha: number): stereoRectifyResult;
stereoRectify(cameraMatrix1: Mat, distCoeffs1: Mat, cameraMatrix2: Mat, distCoeffs2: Mat, imageSize: Size, R: Mat, T: Mat, R1: Mat, R2: Mat, P1: Mat, P2: Mat, Q: Mat, flags: number, alpha: number, newImageSize: Size): stereoRectifyResult;
cameraMatrix1

First camera intrinsic matrix.

distCoeffs1

First camera distortion parameters.

cameraMatrix2

Second camera intrinsic matrix.

distCoeffs2

Second camera distortion parameters.

imageSize

Size of the image used for stereo calibration.

R

Rotation matrix from the coordinate system of the first camera to the second camera, see stereoCalibrate.

T

Translation vector from the coordinate system of the first camera to the second camera, see stereoCalibrate.

R1

Output destination, filled by the native operation. Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix brings points given in the unrectified first camera's coordinate system to points in the rectified first camera's coordinate system. In more technical terms, it performs a change of basis from the unrectified first camera's coordinate system to the rectified first camera's coordinate system.

R2

Output destination, filled by the native operation. Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix brings points given in the unrectified second camera's coordinate system to points in the rectified second camera's coordinate system. In more technical terms, it performs a change of basis from the unrectified second camera's coordinate system to the rectified second camera's coordinate system.

P1

Output destination, filled by the native operation. Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera, i.e. it projects points given in the rectified first camera coordinate system into the rectified first camera's image.

P2

Output destination, filled by the native operation. Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera, i.e. it projects points given in the rectified first camera coordinate system into the rectified second camera's image.

Q

Output destination, filled by the native operation. Output 4 \times 4 disparity-to-depth mapping matrix (see reprojectImageTo3D).

flags

Operation flags that may be zero or STEREO_ZERO_DISPARITY . If the flag is set, the function makes the principal points of each camera have the same pixel coordinates in the rectified views. And if the flag is not set, the function may still shift the images in the horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the useful image area.

alpha

Free scaling parameter. If it is -1 or absent, the function performs the default scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified images are zoomed and shifted so that only valid pixels are visible (no black areas after rectification). alpha=1 means that the rectified image is decimated and shifted so that all the pixels from the original images from the cameras are retained in the rectified images (no source image pixels are lost). Any intermediate value yields an intermediate result between those two extreme cases.

newImageSize

New image resolution after rectification. The same size should be passed to #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0) is passed (default), it is set to the original imageSize . Setting it to a larger value can help you preserve details in the original image, especially when there is a big radial distortion.

Returns

The stereoRectifyResult result. Scalar output parameters are returned as named fields in this object. Release returned native handles with using or delete(), including handles nested in results.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.