|
OpenCV for Unity 3.0.4
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/5.0/index.html ) for the details of the argument of the method.
|
Static Public Member Functions | |
| static void | filterSpeckles (Mat img, double newVal, int maxSpeckleSize, double maxDiff) |
| Filters off small noise blobs (speckles) in the disparity map. | |
| static void | filterSpeckles (Mat img, double newVal, int maxSpeckleSize, double maxDiff, Mat buf) |
| Filters off small noise blobs (speckles) in the disparity map. | |
| static void | fisheye_stereoRectify (Mat K1, Mat D1, Mat K2, Mat D2, in Vec2d imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags) |
| Stereo rectification for fisheye camera model. | |
| static void | fisheye_stereoRectify (Mat K1, Mat D1, Mat K2, Mat D2, in Vec2d imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, in Vec2d newImageSize) |
| Stereo rectification for fisheye camera model. | |
| static void | fisheye_stereoRectify (Mat K1, Mat D1, Mat K2, Mat D2, in Vec2d imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, in Vec2d newImageSize, double balance) |
| Stereo rectification for fisheye camera model. | |
| static void | fisheye_stereoRectify (Mat K1, Mat D1, Mat K2, Mat D2, in Vec2d imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, in Vec2d newImageSize, double balance, double fov_scale) |
| Stereo rectification for fisheye camera model. | |
| static void | fisheye_stereoRectify (Mat K1, Mat D1, Mat K2, Mat D2, in(double width, double height) imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags) |
| Stereo rectification for fisheye camera model. | |
| static void | fisheye_stereoRectify (Mat K1, Mat D1, Mat K2, Mat D2, in(double width, double height) imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, in(double width, double height) newImageSize) |
| Stereo rectification for fisheye camera model. | |
| static void | fisheye_stereoRectify (Mat K1, Mat D1, Mat K2, Mat D2, in(double width, double height) imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, in(double width, double height) newImageSize, double balance) |
| Stereo rectification for fisheye camera model. | |
| static void | fisheye_stereoRectify (Mat K1, Mat D1, Mat K2, Mat D2, in(double width, double height) imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, in(double width, double height) newImageSize, double balance, double fov_scale) |
| Stereo rectification for fisheye camera model. | |
| static void | fisheye_stereoRectify (Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags) |
| Stereo rectification for fisheye camera model. | |
| static void | fisheye_stereoRectify (Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, Size newImageSize) |
| Stereo rectification for fisheye camera model. | |
| static void | fisheye_stereoRectify (Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, Size newImageSize, double balance) |
| Stereo rectification for fisheye camera model. | |
| static void | fisheye_stereoRectify (Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, Size newImageSize, double balance, double fov_scale) |
| Stereo rectification for fisheye camera model. | |
| static Rect | getValidDisparityROI (Rect roi1, Rect roi2, int minDisparity, int numberOfDisparities, int blockSize) |
| static int int int int height | getValidDisparityROIAsValueTuple (in(int x, int y, int width, int height) roi1,(int x, int y, int width, int height) roi2, int minDisparity, int numberOfDisparities, int blockSize) |
| static Vec4i | getValidDisparityROIAsVec4i (in Vec4i roi1, Vec4i roi2, int minDisparity, int numberOfDisparities, int blockSize) |
| static void | reprojectImageTo3D (Mat disparity, Mat _3dImage, Mat Q) |
| Reprojects a disparity image to 3D space. | |
| static void | reprojectImageTo3D (Mat disparity, Mat _3dImage, Mat Q, bool handleMissingValues) |
| Reprojects a disparity image to 3D space. | |
| static void | reprojectImageTo3D (Mat disparity, Mat _3dImage, Mat Q, bool handleMissingValues, int ddepth) |
| Reprojects a disparity image to 3D space. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, in Vec2d imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, in Vec2d imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, in Vec2d imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, in Vec2d imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, in Vec2d newImageSize) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, in Vec2d imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, in Vec2d newImageSize, out Vec4i validPixROI1) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, in Vec2d imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, in Vec2d newImageSize, out Vec4i validPixROI1, out Vec4i validPixROI2) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, in(double width, double height) imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, in(double width, double height) imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, in(double width, double height) imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, in(double width, double height) imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, in(double width, double height) newImageSize) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, in(double width, double height) imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, in(double width, double height) newImageSize, out(int x, int y, int width, int height) validPixROI1) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, in(double width, double height) imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, in(double width, double height) newImageSize, out(int x, int y, int width, int height) validPixROI1, out(int x, int y, int width, int height) validPixROI2) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize, Rect validPixROI1) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static void | stereoRectify (Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize, Rect validPixROI1, Rect validPixROI2) |
| Computes rectification transforms for each head of a calibrated stereo camera. | |
| static bool | stereoRectifyUncalibrated (Mat points1, Mat points2, Mat F, in Vec2d imgSize, Mat H1, Mat H2) |
| Computes a rectification transform for an uncalibrated stereo camera. | |
| static bool | stereoRectifyUncalibrated (Mat points1, Mat points2, Mat F, in Vec2d imgSize, Mat H1, Mat H2, double threshold) |
| Computes a rectification transform for an uncalibrated stereo camera. | |
| static bool | stereoRectifyUncalibrated (Mat points1, Mat points2, Mat F, in(double width, double height) imgSize, Mat H1, Mat H2) |
| Computes a rectification transform for an uncalibrated stereo camera. | |
| static bool | stereoRectifyUncalibrated (Mat points1, Mat points2, Mat F, in(double width, double height) imgSize, Mat H1, Mat H2, double threshold) |
| Computes a rectification transform for an uncalibrated stereo camera. | |
| static bool | stereoRectifyUncalibrated (Mat points1, Mat points2, Mat F, Size imgSize, Mat H1, Mat H2) |
| Computes a rectification transform for an uncalibrated stereo camera. | |
| static bool | stereoRectifyUncalibrated (Mat points1, Mat points2, Mat F, Size imgSize, Mat H1, Mat H2, double threshold) |
| Computes a rectification transform for an uncalibrated stereo camera. | |
| static void | validateDisparity (Mat disparity, Mat cost, int minDisparity, int numberOfDisparities) |
| static void | validateDisparity (Mat disparity, Mat cost, int minDisparity, int numberOfDisparities, int disp12MaxDisp) |
Static Public Attributes | |
| const int | STEREO_ZERO_DISPARITY = 0x00400 |
| C++: enum <unnamed> | |
| static int int int | width |
| static int | x |
| static int int | y |
|
static |
Filters off small noise blobs (speckles) in the disparity map.
| img | The input 16-bit signed disparity image |
| newVal | The disparity value used to paint-off the speckles |
| maxSpeckleSize | The maximum speckle size to consider it a speckle. Larger blobs are not affected by the algorithm |
| maxDiff | Maximum difference between neighbor disparity pixels to put them into the same blob. Note that since StereoBM, StereoSGBM and may be other algorithms return a fixed-point disparity map, where disparity values are multiplied by 16, this scale factor should be taken into account when specifying this parameter value. |
| buf | The optional temporary buffer to avoid memory allocation within the function. |
|
static |
Filters off small noise blobs (speckles) in the disparity map.
| img | The input 16-bit signed disparity image |
| newVal | The disparity value used to paint-off the speckles |
| maxSpeckleSize | The maximum speckle size to consider it a speckle. Larger blobs are not affected by the algorithm |
| maxDiff | Maximum difference between neighbor disparity pixels to put them into the same blob. Note that since StereoBM, StereoSGBM and may be other algorithms return a fixed-point disparity map, where disparity values are multiplied by 16, this scale factor should be taken into account when specifying this parameter value. |
| buf | The optional temporary buffer to avoid memory allocation within the function. |
|
static |
Stereo rectification for fisheye camera model.
| K1 | First camera intrinsic matrix. |
| D1 | First camera distortion parameters. |
| K2 | Second camera intrinsic matrix. |
| D2 | Second camera distortion parameters. |
| imageSize | Size of the image used for stereo calibration. |
| R | Rotation matrix between the coordinate systems of the first and the second cameras. |
| tvec | Translation vector between coordinate systems of the cameras. |
| R1 | Output 3x3 rectification transform (rotation matrix) for the first camera. |
| R2 | Output 3x3 rectification transform (rotation matrix) for the second camera. |
| P1 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera. |
| P2 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera. |
| Q | Output \(4 \times 4\) disparity-to-depth mapping matrix (see reprojectImageTo3D ). |
| flags | 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. |
| 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 larger value can help you preserve details in the original image, especially when there is a big radial distortion. |
| balance | Sets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1]. |
| fov_scale | Divisor for new focal length. |
|
static |
Stereo rectification for fisheye camera model.
| K1 | First camera intrinsic matrix. |
| D1 | First camera distortion parameters. |
| K2 | Second camera intrinsic matrix. |
| D2 | Second camera distortion parameters. |
| imageSize | Size of the image used for stereo calibration. |
| R | Rotation matrix between the coordinate systems of the first and the second cameras. |
| tvec | Translation vector between coordinate systems of the cameras. |
| R1 | Output 3x3 rectification transform (rotation matrix) for the first camera. |
| R2 | Output 3x3 rectification transform (rotation matrix) for the second camera. |
| P1 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera. |
| P2 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera. |
| Q | Output \(4 \times 4\) disparity-to-depth mapping matrix (see reprojectImageTo3D ). |
| flags | 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. |
| 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 larger value can help you preserve details in the original image, especially when there is a big radial distortion. |
| balance | Sets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1]. |
| fov_scale | Divisor for new focal length. |
|
static |
Stereo rectification for fisheye camera model.
| K1 | First camera intrinsic matrix. |
| D1 | First camera distortion parameters. |
| K2 | Second camera intrinsic matrix. |
| D2 | Second camera distortion parameters. |
| imageSize | Size of the image used for stereo calibration. |
| R | Rotation matrix between the coordinate systems of the first and the second cameras. |
| tvec | Translation vector between coordinate systems of the cameras. |
| R1 | Output 3x3 rectification transform (rotation matrix) for the first camera. |
| R2 | Output 3x3 rectification transform (rotation matrix) for the second camera. |
| P1 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera. |
| P2 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera. |
| Q | Output \(4 \times 4\) disparity-to-depth mapping matrix (see reprojectImageTo3D ). |
| flags | 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. |
| 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 larger value can help you preserve details in the original image, especially when there is a big radial distortion. |
| balance | Sets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1]. |
| fov_scale | Divisor for new focal length. |
|
static |
Stereo rectification for fisheye camera model.
| K1 | First camera intrinsic matrix. |
| D1 | First camera distortion parameters. |
| K2 | Second camera intrinsic matrix. |
| D2 | Second camera distortion parameters. |
| imageSize | Size of the image used for stereo calibration. |
| R | Rotation matrix between the coordinate systems of the first and the second cameras. |
| tvec | Translation vector between coordinate systems of the cameras. |
| R1 | Output 3x3 rectification transform (rotation matrix) for the first camera. |
| R2 | Output 3x3 rectification transform (rotation matrix) for the second camera. |
| P1 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera. |
| P2 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera. |
| Q | Output \(4 \times 4\) disparity-to-depth mapping matrix (see reprojectImageTo3D ). |
| flags | 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. |
| 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 larger value can help you preserve details in the original image, especially when there is a big radial distortion. |
| balance | Sets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1]. |
| fov_scale | Divisor for new focal length. |
|
static |
Stereo rectification for fisheye camera model.
| K1 | First camera intrinsic matrix. |
| D1 | First camera distortion parameters. |
| K2 | Second camera intrinsic matrix. |
| D2 | Second camera distortion parameters. |
| imageSize | Size of the image used for stereo calibration. |
| R | Rotation matrix between the coordinate systems of the first and the second cameras. |
| tvec | Translation vector between coordinate systems of the cameras. |
| R1 | Output 3x3 rectification transform (rotation matrix) for the first camera. |
| R2 | Output 3x3 rectification transform (rotation matrix) for the second camera. |
| P1 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera. |
| P2 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera. |
| Q | Output \(4 \times 4\) disparity-to-depth mapping matrix (see reprojectImageTo3D ). |
| flags | 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. |
| 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 larger value can help you preserve details in the original image, especially when there is a big radial distortion. |
| balance | Sets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1]. |
| fov_scale | Divisor for new focal length. |
|
static |
Stereo rectification for fisheye camera model.
| K1 | First camera intrinsic matrix. |
| D1 | First camera distortion parameters. |
| K2 | Second camera intrinsic matrix. |
| D2 | Second camera distortion parameters. |
| imageSize | Size of the image used for stereo calibration. |
| R | Rotation matrix between the coordinate systems of the first and the second cameras. |
| tvec | Translation vector between coordinate systems of the cameras. |
| R1 | Output 3x3 rectification transform (rotation matrix) for the first camera. |
| R2 | Output 3x3 rectification transform (rotation matrix) for the second camera. |
| P1 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera. |
| P2 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera. |
| Q | Output \(4 \times 4\) disparity-to-depth mapping matrix (see reprojectImageTo3D ). |
| flags | 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. |
| 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 larger value can help you preserve details in the original image, especially when there is a big radial distortion. |
| balance | Sets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1]. |
| fov_scale | Divisor for new focal length. |
|
static |
Stereo rectification for fisheye camera model.
| K1 | First camera intrinsic matrix. |
| D1 | First camera distortion parameters. |
| K2 | Second camera intrinsic matrix. |
| D2 | Second camera distortion parameters. |
| imageSize | Size of the image used for stereo calibration. |
| R | Rotation matrix between the coordinate systems of the first and the second cameras. |
| tvec | Translation vector between coordinate systems of the cameras. |
| R1 | Output 3x3 rectification transform (rotation matrix) for the first camera. |
| R2 | Output 3x3 rectification transform (rotation matrix) for the second camera. |
| P1 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera. |
| P2 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera. |
| Q | Output \(4 \times 4\) disparity-to-depth mapping matrix (see reprojectImageTo3D ). |
| flags | 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. |
| 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 larger value can help you preserve details in the original image, especially when there is a big radial distortion. |
| balance | Sets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1]. |
| fov_scale | Divisor for new focal length. |
|
static |
Stereo rectification for fisheye camera model.
| K1 | First camera intrinsic matrix. |
| D1 | First camera distortion parameters. |
| K2 | Second camera intrinsic matrix. |
| D2 | Second camera distortion parameters. |
| imageSize | Size of the image used for stereo calibration. |
| R | Rotation matrix between the coordinate systems of the first and the second cameras. |
| tvec | Translation vector between coordinate systems of the cameras. |
| R1 | Output 3x3 rectification transform (rotation matrix) for the first camera. |
| R2 | Output 3x3 rectification transform (rotation matrix) for the second camera. |
| P1 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera. |
| P2 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera. |
| Q | Output \(4 \times 4\) disparity-to-depth mapping matrix (see reprojectImageTo3D ). |
| flags | 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. |
| 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 larger value can help you preserve details in the original image, especially when there is a big radial distortion. |
| balance | Sets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1]. |
| fov_scale | Divisor for new focal length. |
|
static |
Stereo rectification for fisheye camera model.
| K1 | First camera intrinsic matrix. |
| D1 | First camera distortion parameters. |
| K2 | Second camera intrinsic matrix. |
| D2 | Second camera distortion parameters. |
| imageSize | Size of the image used for stereo calibration. |
| R | Rotation matrix between the coordinate systems of the first and the second cameras. |
| tvec | Translation vector between coordinate systems of the cameras. |
| R1 | Output 3x3 rectification transform (rotation matrix) for the first camera. |
| R2 | Output 3x3 rectification transform (rotation matrix) for the second camera. |
| P1 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera. |
| P2 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera. |
| Q | Output \(4 \times 4\) disparity-to-depth mapping matrix (see reprojectImageTo3D ). |
| flags | 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. |
| 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 larger value can help you preserve details in the original image, especially when there is a big radial distortion. |
| balance | Sets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1]. |
| fov_scale | Divisor for new focal length. |
|
static |
Stereo rectification for fisheye camera model.
| K1 | First camera intrinsic matrix. |
| D1 | First camera distortion parameters. |
| K2 | Second camera intrinsic matrix. |
| D2 | Second camera distortion parameters. |
| imageSize | Size of the image used for stereo calibration. |
| R | Rotation matrix between the coordinate systems of the first and the second cameras. |
| tvec | Translation vector between coordinate systems of the cameras. |
| R1 | Output 3x3 rectification transform (rotation matrix) for the first camera. |
| R2 | Output 3x3 rectification transform (rotation matrix) for the second camera. |
| P1 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera. |
| P2 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera. |
| Q | Output \(4 \times 4\) disparity-to-depth mapping matrix (see reprojectImageTo3D ). |
| flags | 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. |
| 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 larger value can help you preserve details in the original image, especially when there is a big radial distortion. |
| balance | Sets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1]. |
| fov_scale | Divisor for new focal length. |
|
static |
Stereo rectification for fisheye camera model.
| K1 | First camera intrinsic matrix. |
| D1 | First camera distortion parameters. |
| K2 | Second camera intrinsic matrix. |
| D2 | Second camera distortion parameters. |
| imageSize | Size of the image used for stereo calibration. |
| R | Rotation matrix between the coordinate systems of the first and the second cameras. |
| tvec | Translation vector between coordinate systems of the cameras. |
| R1 | Output 3x3 rectification transform (rotation matrix) for the first camera. |
| R2 | Output 3x3 rectification transform (rotation matrix) for the second camera. |
| P1 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera. |
| P2 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera. |
| Q | Output \(4 \times 4\) disparity-to-depth mapping matrix (see reprojectImageTo3D ). |
| flags | 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. |
| 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 larger value can help you preserve details in the original image, especially when there is a big radial distortion. |
| balance | Sets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1]. |
| fov_scale | Divisor for new focal length. |
|
static |
Stereo rectification for fisheye camera model.
| K1 | First camera intrinsic matrix. |
| D1 | First camera distortion parameters. |
| K2 | Second camera intrinsic matrix. |
| D2 | Second camera distortion parameters. |
| imageSize | Size of the image used for stereo calibration. |
| R | Rotation matrix between the coordinate systems of the first and the second cameras. |
| tvec | Translation vector between coordinate systems of the cameras. |
| R1 | Output 3x3 rectification transform (rotation matrix) for the first camera. |
| R2 | Output 3x3 rectification transform (rotation matrix) for the second camera. |
| P1 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera. |
| P2 | Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera. |
| Q | Output \(4 \times 4\) disparity-to-depth mapping matrix (see reprojectImageTo3D ). |
| flags | 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. |
| 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 larger value can help you preserve details in the original image, especially when there is a big radial distortion. |
| balance | Sets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1]. |
| fov_scale | Divisor for new focal length. |
|
static |
|
static |
|
static |
|
static |
Reprojects a disparity image to 3D space.
| disparity | Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit floating-point disparity image. The values of 8-bit / 16-bit signed formats are assumed to have no fractional bits. If the disparity is 16-bit signed format, as computed by StereoBM or StereoSGBM and maybe other algorithms, it should be divided by 16 (and scaled to float) before being used here. |
| _3dImage | Output 3-channel floating-point image of the same size as disparity. Each element of _3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity map. If one uses Q obtained by stereoRectify, then the returned points are represented in the first camera's rectified coordinate system. |
| Q | \(4 \times 4\) perspective transformation matrix that can be obtained with stereoRectify. |
| handleMissingValues | Indicates, whether the function should handle missing values (i.e. points where the disparity was not computed). If handleMissingValues=true, then pixels with the minimal disparity that corresponds to the outliers (see StereoMatcher.compute ) are transformed to 3D points with a very large Z value (currently set to 10000). |
| ddepth | The optional output array depth. If it is -1, the output image will have CV_32F depth. ddepth can also be set to CV_16S, CV_32S or CV_32F. |
The function transforms a single-channel disparity map to a 3-channel image representing a 3D surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it computes:
\[\begin{bmatrix} X \\ Y \\ Z \\ W \end{bmatrix} = Q \begin{bmatrix} x \\ y \\ \texttt{disparity} (x,y) \\ 1 \end{bmatrix}.\]
|
static |
Reprojects a disparity image to 3D space.
| disparity | Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit floating-point disparity image. The values of 8-bit / 16-bit signed formats are assumed to have no fractional bits. If the disparity is 16-bit signed format, as computed by StereoBM or StereoSGBM and maybe other algorithms, it should be divided by 16 (and scaled to float) before being used here. |
| _3dImage | Output 3-channel floating-point image of the same size as disparity. Each element of _3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity map. If one uses Q obtained by stereoRectify, then the returned points are represented in the first camera's rectified coordinate system. |
| Q | \(4 \times 4\) perspective transformation matrix that can be obtained with stereoRectify. |
| handleMissingValues | Indicates, whether the function should handle missing values (i.e. points where the disparity was not computed). If handleMissingValues=true, then pixels with the minimal disparity that corresponds to the outliers (see StereoMatcher.compute ) are transformed to 3D points with a very large Z value (currently set to 10000). |
| ddepth | The optional output array depth. If it is -1, the output image will have CV_32F depth. ddepth can also be set to CV_16S, CV_32S or CV_32F. |
The function transforms a single-channel disparity map to a 3-channel image representing a 3D surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it computes:
\[\begin{bmatrix} X \\ Y \\ Z \\ W \end{bmatrix} = Q \begin{bmatrix} x \\ y \\ \texttt{disparity} (x,y) \\ 1 \end{bmatrix}.\]
|
static |
Reprojects a disparity image to 3D space.
| disparity | Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit floating-point disparity image. The values of 8-bit / 16-bit signed formats are assumed to have no fractional bits. If the disparity is 16-bit signed format, as computed by StereoBM or StereoSGBM and maybe other algorithms, it should be divided by 16 (and scaled to float) before being used here. |
| _3dImage | Output 3-channel floating-point image of the same size as disparity. Each element of _3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity map. If one uses Q obtained by stereoRectify, then the returned points are represented in the first camera's rectified coordinate system. |
| Q | \(4 \times 4\) perspective transformation matrix that can be obtained with stereoRectify. |
| handleMissingValues | Indicates, whether the function should handle missing values (i.e. points where the disparity was not computed). If handleMissingValues=true, then pixels with the minimal disparity that corresponds to the outliers (see StereoMatcher.compute ) are transformed to 3D points with a very large Z value (currently set to 10000). |
| ddepth | The optional output array depth. If it is -1, the output image will have CV_32F depth. ddepth can also be set to CV_16S, CV_32S or CV_32F. |
The function transforms a single-channel disparity map to a 3-channel image representing a 3D surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it computes:
\[\begin{bmatrix} X \\ Y \\ Z \\ W \end{bmatrix} = Q \begin{bmatrix} x \\ y \\ \texttt{disparity} (x,y) \\ 1 \end{bmatrix}.\]
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes rectification transforms for each head of a calibrated stereo camera.
| 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 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 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 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 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 \(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. |
| validPixROI1 | Optional 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 (see the picture below). |
| validPixROI2 | Optional 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 (see the picture below). |
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \]
where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if STEREO_ZERO_DISPARITY is set.
\[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\]
\[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\]
\[\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \]
where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if STEREO_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera.
See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels.
|
static |
Computes a rectification transform for an uncalibrated stereo camera.
| points1 | Array of feature points in the first image. |
| points2 | The corresponding points in the second image. The same formats as in #findFundamentalMat are supported. |
| F | Input fundamental matrix. It can be computed from the same set of point pairs using #findFundamentalMat . |
| imgSize | Size of the image. |
| H1 | Output rectification homography matrix for the first image. |
| H2 | Output rectification homography matrix for the second image. |
| threshold | Optional threshold used to filter out the outliers. If the parameter is greater than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points for which \(|\texttt{points2[i]}^T \cdot \texttt{F} \cdot \texttt{points1[i]}|>\texttt{threshold}\) ) are rejected prior to computing the homographies. Otherwise, all the points are considered inliers. |
The function computes the rectification transformations without knowing intrinsic parameters of the cameras and their relative position in the space, which explains the suffix "uncalibrated". Another related difference from stereoRectify is that the function outputs not the rectification transformations in the object (3D) space, but the planar perspective transformations encoded by the homography matrices H1 and H2 . The function implements the algorithm [Hartley99] .
|
static |
Computes a rectification transform for an uncalibrated stereo camera.
| points1 | Array of feature points in the first image. |
| points2 | The corresponding points in the second image. The same formats as in #findFundamentalMat are supported. |
| F | Input fundamental matrix. It can be computed from the same set of point pairs using #findFundamentalMat . |
| imgSize | Size of the image. |
| H1 | Output rectification homography matrix for the first image. |
| H2 | Output rectification homography matrix for the second image. |
| threshold | Optional threshold used to filter out the outliers. If the parameter is greater than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points for which \(|\texttt{points2[i]}^T \cdot \texttt{F} \cdot \texttt{points1[i]}|>\texttt{threshold}\) ) are rejected prior to computing the homographies. Otherwise, all the points are considered inliers. |
The function computes the rectification transformations without knowing intrinsic parameters of the cameras and their relative position in the space, which explains the suffix "uncalibrated". Another related difference from stereoRectify is that the function outputs not the rectification transformations in the object (3D) space, but the planar perspective transformations encoded by the homography matrices H1 and H2 . The function implements the algorithm [Hartley99] .
|
static |
Computes a rectification transform for an uncalibrated stereo camera.
| points1 | Array of feature points in the first image. |
| points2 | The corresponding points in the second image. The same formats as in #findFundamentalMat are supported. |
| F | Input fundamental matrix. It can be computed from the same set of point pairs using #findFundamentalMat . |
| imgSize | Size of the image. |
| H1 | Output rectification homography matrix for the first image. |
| H2 | Output rectification homography matrix for the second image. |
| threshold | Optional threshold used to filter out the outliers. If the parameter is greater than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points for which \(|\texttt{points2[i]}^T \cdot \texttt{F} \cdot \texttt{points1[i]}|>\texttt{threshold}\) ) are rejected prior to computing the homographies. Otherwise, all the points are considered inliers. |
The function computes the rectification transformations without knowing intrinsic parameters of the cameras and their relative position in the space, which explains the suffix "uncalibrated". Another related difference from stereoRectify is that the function outputs not the rectification transformations in the object (3D) space, but the planar perspective transformations encoded by the homography matrices H1 and H2 . The function implements the algorithm [Hartley99] .
|
static |
Computes a rectification transform for an uncalibrated stereo camera.
| points1 | Array of feature points in the first image. |
| points2 | The corresponding points in the second image. The same formats as in #findFundamentalMat are supported. |
| F | Input fundamental matrix. It can be computed from the same set of point pairs using #findFundamentalMat . |
| imgSize | Size of the image. |
| H1 | Output rectification homography matrix for the first image. |
| H2 | Output rectification homography matrix for the second image. |
| threshold | Optional threshold used to filter out the outliers. If the parameter is greater than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points for which \(|\texttt{points2[i]}^T \cdot \texttt{F} \cdot \texttt{points1[i]}|>\texttt{threshold}\) ) are rejected prior to computing the homographies. Otherwise, all the points are considered inliers. |
The function computes the rectification transformations without knowing intrinsic parameters of the cameras and their relative position in the space, which explains the suffix "uncalibrated". Another related difference from stereoRectify is that the function outputs not the rectification transformations in the object (3D) space, but the planar perspective transformations encoded by the homography matrices H1 and H2 . The function implements the algorithm [Hartley99] .
|
static |
Computes a rectification transform for an uncalibrated stereo camera.
| points1 | Array of feature points in the first image. |
| points2 | The corresponding points in the second image. The same formats as in #findFundamentalMat are supported. |
| F | Input fundamental matrix. It can be computed from the same set of point pairs using #findFundamentalMat . |
| imgSize | Size of the image. |
| H1 | Output rectification homography matrix for the first image. |
| H2 | Output rectification homography matrix for the second image. |
| threshold | Optional threshold used to filter out the outliers. If the parameter is greater than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points for which \(|\texttt{points2[i]}^T \cdot \texttt{F} \cdot \texttt{points1[i]}|>\texttt{threshold}\) ) are rejected prior to computing the homographies. Otherwise, all the points are considered inliers. |
The function computes the rectification transformations without knowing intrinsic parameters of the cameras and their relative position in the space, which explains the suffix "uncalibrated". Another related difference from stereoRectify is that the function outputs not the rectification transformations in the object (3D) space, but the planar perspective transformations encoded by the homography matrices H1 and H2 . The function implements the algorithm [Hartley99] .
|
static |
Computes a rectification transform for an uncalibrated stereo camera.
| points1 | Array of feature points in the first image. |
| points2 | The corresponding points in the second image. The same formats as in #findFundamentalMat are supported. |
| F | Input fundamental matrix. It can be computed from the same set of point pairs using #findFundamentalMat . |
| imgSize | Size of the image. |
| H1 | Output rectification homography matrix for the first image. |
| H2 | Output rectification homography matrix for the second image. |
| threshold | Optional threshold used to filter out the outliers. If the parameter is greater than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points for which \(|\texttt{points2[i]}^T \cdot \texttt{F} \cdot \texttt{points1[i]}|>\texttt{threshold}\) ) are rejected prior to computing the homographies. Otherwise, all the points are considered inliers. |
The function computes the rectification transformations without knowing intrinsic parameters of the cameras and their relative position in the space, which explains the suffix "uncalibrated". Another related difference from stereoRectify is that the function outputs not the rectification transformations in the object (3D) space, but the planar perspective transformations encoded by the homography matrices H1 and H2 . The function implements the algorithm [Hartley99] .
|
static |
|
static |
|
static |
C++: enum <unnamed>
|
static |
|
static |
|
static |