| Cv2StereoRectify Method (Double, Double, Double, Double, Size, Double, Double, Double, Double, Double, Double, Double, StereoRectificationFlags, Double, NullableSize) |
computes the rectification transformation for a stereo camera from its intrinsic and extrinsic parameters
Namespace:
OpenCvSharp
Assembly:
OpenCvSharp (in OpenCvSharp.dll) Version: 1.0.0
Syntax public static void StereoRectify(
double[,] cameraMatrix1,
double[] distCoeffs1,
double[,] cameraMatrix2,
double[] distCoeffs2,
Size imageSize,
double[,] R,
double[] T,
out double[,] R1,
out double[,] R2,
out double[,] P1,
out double[,] P2,
out double[,] Q,
StereoRectificationFlags flags = StereoRectificationFlags.ZeroDisparity,
double alpha = -1,
Nullable<Size> newImageSize = null
)
Public Shared Sub StereoRectify (
cameraMatrix1 As Double(,),
distCoeffs1 As Double(),
cameraMatrix2 As Double(,),
distCoeffs2 As Double(),
imageSize As Size,
R As Double(,),
T As Double(),
<OutAttribute> ByRef R1 As Double(,),
<OutAttribute> ByRef R2 As Double(,),
<OutAttribute> ByRef P1 As Double(,),
<OutAttribute> ByRef P2 As Double(,),
<OutAttribute> ByRef Q As Double(,),
Optional flags As StereoRectificationFlags = StereoRectificationFlags.ZeroDisparity,
Optional alpha As Double = -1,
Optional newImageSize As Nullable(Of Size) = Nothing
)
public:
static void StereoRectify(
array<double,2>^ cameraMatrix1,
array<double>^ distCoeffs1,
array<double,2>^ cameraMatrix2,
array<double>^ distCoeffs2,
Size imageSize,
array<double,2>^ R,
array<double>^ T,
[OutAttribute] array<double,2>^% R1,
[OutAttribute] array<double,2>^% R2,
[OutAttribute] array<double,2>^% P1,
[OutAttribute] array<double,2>^% P2,
[OutAttribute] array<double,2>^% Q,
StereoRectificationFlags flags = StereoRectificationFlags::ZeroDisparity,
double alpha = -1,
Nullable<Size> newImageSize = nullptr
)
static member StereoRectify :
cameraMatrix1 : float[,] *
distCoeffs1 : float[] *
cameraMatrix2 : float[,] *
distCoeffs2 : float[] *
imageSize : Size *
R : float[,] *
T : float[] *
R1 : float[,] byref *
R2 : float[,] byref *
P1 : float[,] byref *
P2 : float[,] byref *
Q : float[,] byref *
?flags : StereoRectificationFlags *
?alpha : float *
?newImageSize : Nullable<Size>
(* Defaults:
let _flags = defaultArg flags StereoRectificationFlags.ZeroDisparity
let _alpha = defaultArg alpha -1
let _newImageSize = defaultArg newImageSize null
*)
-> unit
Parameters
- cameraMatrix1
- Type: SystemDouble
First camera matrix. - distCoeffs1
- Type: SystemDouble
First camera distortion parameters. - cameraMatrix2
- Type: SystemDouble
Second camera matrix. - distCoeffs2
- Type: SystemDouble
Second camera distortion parameters. - imageSize
- Type: OpenCvSharpSize
Size of the image used for stereo calibration. - R
- Type: SystemDouble
Rotation matrix between the coordinate systems of the first and the second cameras. - T
- Type: SystemDouble
Translation vector between coordinate systems of the cameras. - R1
- Type: SystemDouble
Output 3x3 rectification transform (rotation matrix) for the first camera. - R2
- Type: SystemDouble
Output 3x3 rectification transform (rotation matrix) for the second camera. - P1
- Type: SystemDouble
Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera. - P2
- Type: SystemDouble
Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera. - Q
- Type: SystemDouble
Output 4x4 disparity-to-depth mapping matrix (see reprojectImageTo3D() ). - flags (Optional)
- Type: OpenCvSharpStereoRectificationFlags
Operation flags that may be zero or CV_CALIB_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 (Optional)
- Type: SystemDouble
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). Obviously, any intermediate value yields an intermediate result between those two extreme cases. - newImageSize (Optional)
- Type: SystemNullableSize
New image resolution after rectification. The same size should be passed to initUndistortRectifyMap(). When (0,0) is passed (default), it is set to the original imageSize .
Setting it to larger value can help you preserve details in the original image, especially when there is a big radial distortion.
See Also