Method StereoRectify
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
StereoRectify(InputArray, InputArray, InputArray, InputArray, Size, InputArray, InputArray, OutputArray, OutputArray, OutputArray, OutputArray, OutputArray, StereoRectificationFlags, double, Size?)
computes the rectification transformation for a stereo camera from its intrinsic and extrinsic parameters
public static void StereoRectify(InputArray cameraMatrix1, InputArray distCoeffs1, InputArray cameraMatrix2, InputArray distCoeffs2, Size imageSize, InputArray R, InputArray T, OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, StereoRectificationFlags flags = StereoRectificationFlags.ZeroDisparity, double alpha = -1, Size? newImageSize = null)
Parameters
cameraMatrix1InputArrayFirst camera matrix.
distCoeffs1InputArrayFirst camera distortion parameters.
cameraMatrix2InputArraySecond camera matrix.
distCoeffs2InputArraySecond camera distortion parameters.
imageSizeSizeSize of the image used for stereo calibration.
RInputArrayRotation matrix between the coordinate systems of the first and the second cameras.
TInputArrayTranslation vector between coordinate systems of the cameras.
R1OutputArrayOutput 3x3 rectification transform (rotation matrix) for the first camera.
R2OutputArrayOutput 3x3 rectification transform (rotation matrix) for the second camera.
P1OutputArrayOutput 3x4 projection matrix in the new (rectified) coordinate systems for the first camera.
P2OutputArrayOutput 3x4 projection matrix in the new (rectified) coordinate systems for the second camera.
QOutputArrayOutput 4x4 disparity-to-depth mapping matrix (see reprojectImageTo3D() ).
flagsStereoRectificationFlagsOperation 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.
alphadoubleFree 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.
newImageSizeSize?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.
StereoRectify(InputArray, InputArray, InputArray, InputArray, Size, InputArray, InputArray, OutputArray, OutputArray, OutputArray, OutputArray, OutputArray, StereoRectificationFlags, double, Size, out Rect, out Rect)
computes the rectification transformation for a stereo camera from its intrinsic and extrinsic parameters
public static void StereoRectify(InputArray cameraMatrix1, InputArray distCoeffs1, InputArray cameraMatrix2, InputArray distCoeffs2, Size imageSize, InputArray R, InputArray T, OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, StereoRectificationFlags flags, double alpha, Size newImageSize, out Rect validPixROI1, out Rect validPixROI2)
Parameters
cameraMatrix1InputArrayFirst camera matrix.
distCoeffs1InputArrayFirst camera distortion parameters.
cameraMatrix2InputArraySecond camera matrix.
distCoeffs2InputArraySecond camera distortion parameters.
imageSizeSizeSize of the image used for stereo calibration.
RInputArrayRotation matrix between the coordinate systems of the first and the second cameras.
TInputArrayTranslation vector between coordinate systems of the cameras.
R1OutputArrayOutput 3x3 rectification transform (rotation matrix) for the first camera.
R2OutputArrayOutput 3x3 rectification transform (rotation matrix) for the second camera.
P1OutputArrayOutput 3x4 projection matrix in the new (rectified) coordinate systems for the first camera.
P2OutputArrayOutput 3x4 projection matrix in the new (rectified) coordinate systems for the second camera.
QOutputArrayOutput 4x4 disparity-to-depth mapping matrix (see reprojectImageTo3D() ).
flagsStereoRectificationFlagsOperation 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.
alphadoubleFree 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.
newImageSizeSizeNew 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.
validPixROI1RectOptional output rectangles inside the rectified images where all the pixels are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller.
validPixROI2RectOptional output rectangles inside the rectified images where all the pixels are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller.
StereoRectify(double[,], double[], double[,], double[], Size, double[,], double[], out double[,], out double[,], out double[,], out double[,], out double[,], StereoRectificationFlags, double, Size?)
computes the rectification transformation for a stereo camera from its intrinsic and extrinsic parameters
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, Size? newImageSize = null)
Parameters
cameraMatrix1double[,]First camera matrix.
distCoeffs1double[]First camera distortion parameters.
cameraMatrix2double[,]Second camera matrix.
distCoeffs2double[]Second camera distortion parameters.
imageSizeSizeSize of the image used for stereo calibration.
Rdouble[,]Rotation matrix between the coordinate systems of the first and the second cameras.
Tdouble[]Translation vector between coordinate systems of the cameras.
R1double[,]Output 3x3 rectification transform (rotation matrix) for the first camera.
R2double[,]Output 3x3 rectification transform (rotation matrix) for the second camera.
P1double[,]Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera.
P2double[,]Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera.
Qdouble[,]Output 4x4 disparity-to-depth mapping matrix (see reprojectImageTo3D() ).
flagsStereoRectificationFlagsOperation 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.
alphadoubleFree 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.
newImageSizeSize?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.
StereoRectify(double[,], double[], double[,], double[], Size, double[,], double[], out double[,], out double[,], out double[,], out double[,], out double[,], StereoRectificationFlags, double, Size, out Rect, out Rect)
computes the rectification transformation for a stereo camera from its intrinsic and extrinsic parameters
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, double alpha, Size newImageSize, out Rect validPixROI1, out Rect validPixROI2)
Parameters
cameraMatrix1double[,]First camera matrix.
distCoeffs1double[]First camera distortion parameters.
cameraMatrix2double[,]Second camera matrix.
distCoeffs2double[]Second camera distortion parameters.
imageSizeSizeSize of the image used for stereo calibration.
Rdouble[,]Rotation matrix between the coordinate systems of the first and the second cameras.
Tdouble[]Translation vector between coordinate systems of the cameras.
R1double[,]Output 3x3 rectification transform (rotation matrix) for the first camera.
R2double[,]Output 3x3 rectification transform (rotation matrix) for the second camera.
P1double[,]Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera.
P2double[,]Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera.
Qdouble[,]Output 4x4 disparity-to-depth mapping matrix (see reprojectImageTo3D() ).
flagsStereoRectificationFlagsOperation 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.
alphadoubleFree 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.
newImageSizeSizeNew 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.
validPixROI1RectOptional output rectangles inside the rectified images where all the pixels are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller.
validPixROI2RectOptional output rectangles inside the rectified images where all the pixels are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller.