Class Cv2.FishEye
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
The methods in this class use a so-called fisheye camera model.
public static class Cv2.FishEye
- Inheritance
-
Cv2.FishEye
- Inherited Members
Methods
Calibrate(IEnumerable<Mat>, IEnumerable<Mat>, Size, InputOutputArray, InputOutputArray, out IEnumerable<Mat>, out IEnumerable<Mat>, FishEyeCalibrationFlags, TermCriteria?)
Performs camera calibaration
public static double Calibrate(IEnumerable<Mat> objectPoints, IEnumerable<Mat> imagePoints, Size imageSize, InputOutputArray k, InputOutputArray d, out IEnumerable<Mat> rvecs, out IEnumerable<Mat> tvecs, FishEyeCalibrationFlags flags = FishEyeCalibrationFlags.None, TermCriteria? criteria = null)
Parameters
objectPointsIEnumerable<Mat>vector of vectors of calibration pattern points in the calibration pattern coordinate space.
imagePointsIEnumerable<Mat>vector of vectors of the projections of calibration pattern points. imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to objectPoints[i].size() for each i.
imageSizeSizeSize of the image used only to initialize the intrinsic camera matrix.
kInputOutputArrayOutput 3x3 floating-point camera matrix
dInputOutputArrayOutput vector of distortion coefficients (k_1, k_2, k_3, k_4).
rvecsIEnumerable<Mat>Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view. That is, each k-th rotation vector together with the corresponding k-th translation vector(see the next output parameter description) brings the calibration pattern from the model coordinate space(in which object points are specified) to the world coordinate space, that is, a real position of the calibration pattern in the k-th pattern view(k= 0.. * M * -1).
tvecsIEnumerable<Mat>Output vector of translation vectors estimated for each pattern view.
flagsFishEyeCalibrationFlagsDifferent flags that may be zero or a combination of flag values
criteriaTermCriteria?Termination criteria for the iterative optimization algorithm.
Returns
DistortPoints(InputArray, OutputArray, InputArray, InputArray, double)
Distorts 2D points using fisheye model.
public static void DistortPoints(InputArray undistorted, OutputArray distorted, InputArray k, InputArray d, double alpha = 0)
Parameters
undistortedInputArrayArray of object points, 1xN/Nx1 2-channel (or vector<Point2f> ), where N is the number of points in the view.
distortedOutputArrayOutput array of image points, 1xN/Nx1 2-channel, or vector<Point2f> .
kInputArrayCamera matrix
dInputArrayInput vector of distortion coefficients
alphadoubleThe skew coefficient.
EstimateNewCameraMatrixForUndistortRectify(InputArray, InputArray, Size, InputArray, OutputArray, double, Size, double)
Estimates new camera matrix for undistortion or rectification.
public static void EstimateNewCameraMatrixForUndistortRectify(InputArray k, InputArray d, Size imageSize, InputArray r, OutputArray p, double balance = 0, Size newSize = default, double fovScale = 1)
Parameters
kInputArrayCamera matrix
dInputArrayInput vector of distortion coefficients (k_1, k_2, k_3, k_4).
imageSizeSizerInputArrayRectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel
pOutputArrayNew camera matrix (3x3) or new projection matrix (3x4)
balancedoubleSets the new focal length in range between the min focal length and the max focal length.Balance is in range of[0, 1].
newSizeSizefovScaledoubleDivisor for new focal length.
InitUndistortRectifyMap(InputArray, InputArray, InputArray, InputArray, Size, int, OutputArray, OutputArray)
Computes undistortion and rectification maps for image transform by cv::remap(). If D is empty zero distortion is used, if R or P is empty identity matrixes are used.
public static void InitUndistortRectifyMap(InputArray k, InputArray d, InputArray r, InputArray p, Size size, int m1type, OutputArray map1, OutputArray map2)
Parameters
kInputArrayCamera matrix
dInputArrayInput vector of distortion coefficients (k_1, k_2, k_3, k_4).
rInputArrayRectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel
pInputArrayNew camera matrix (3x3) or new projection matrix (3x4)
sizeSizeUndistorted image size.
m1typeintType of the first output map that can be CV_32FC1 or CV_16SC2 . See convertMaps() for details.
map1OutputArrayThe first output map.
map2OutputArrayThe second output map.
ProjectPoints(InputArray, OutputArray, InputArray, InputArray, InputArray, InputArray, double, OutputArray?)
Projects points using fisheye model.
The function computes projections of 3D points to the image plane given intrinsic and extrinsic camera parameters.Optionally, the function computes Jacobians - matrices of partial derivatives of image points coordinates(as functions of all the input parameters) with respect to the particular parameters, intrinsic and/or extrinsic.
public static void ProjectPoints(InputArray objectPoints, OutputArray imagePoints, InputArray rvec, InputArray tvec, InputArray k, InputArray d, double alpha = 0, OutputArray? jacobian = null)
Parameters
objectPointsInputArrayArray of object points, 1xN/Nx1 3-channel (or vector<Point3f> ), where N is the number of points in the view.
imagePointsOutputArrayOutput array of image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, or vector<Point2f>.
rvecInputArraytvecInputArraykInputArrayCamera matrix
dInputArrayInput vector of distortion coefficients
alphadoubleThe skew coefficient.
jacobianOutputArrayOptional output 2Nx15 jacobian matrix of derivatives of image points with respect to components of the focal lengths, coordinates of the principal point, distortion coefficients, rotation vector, translation vector, and the skew.In the old interface different components of the jacobian are returned via different output parameters.
StereoCalibrate(IEnumerable<Mat>, IEnumerable<Mat>, IEnumerable<Mat>, InputOutputArray, InputOutputArray, InputOutputArray, InputOutputArray, Size, OutputArray, OutputArray, FishEyeCalibrationFlags, TermCriteria?)
Performs stereo calibration
public static double StereoCalibrate(IEnumerable<Mat> objectPoints, IEnumerable<Mat> imagePoints1, IEnumerable<Mat> imagePoints2, InputOutputArray k1, InputOutputArray d1, InputOutputArray k2, InputOutputArray d2, Size imageSize, OutputArray r, OutputArray t, FishEyeCalibrationFlags flags = FishEyeCalibrationFlags.FixIntrinsic, TermCriteria? criteria = null)
Parameters
objectPointsIEnumerable<Mat>Vector of vectors of the calibration pattern points.
imagePoints1IEnumerable<Mat>Vector of vectors of the projections of the calibration pattern points, observed by the first camera.
imagePoints2IEnumerable<Mat>Vector of vectors of the projections of the calibration pattern points, observed by the second camera.
k1InputOutputArrayInput/output first camera matrix
d1InputOutputArrayInput/output vector of distortion coefficients (k_1, k_2, k_3, k_4) of 4 elements.
k2InputOutputArrayInput/output second camera matrix. The parameter is similar to K1 .
d2InputOutputArrayInput/output lens distortion coefficients for the second camera. The parameter is similar to D1.
imageSizeSizeSize of the image used only to initialize intrinsic camera matrix.
rOutputArrayOutput rotation matrix between the 1st and the 2nd camera coordinate systems.
tOutputArrayOutput translation vector between the coordinate systems of the cameras.
flagsFishEyeCalibrationFlagsDifferent flags that may be zero or a combination of the FishEyeCalibrationFlags values
criteriaTermCriteria?Termination criteria for the iterative optimization algorithm.
Returns
StereoRectify(InputArray, InputArray, InputArray, InputArray, Size, InputArray, InputArray, OutputArray, OutputArray, OutputArray, OutputArray, OutputArray, FishEyeCalibrationFlags, Size, double, double)
Stereo rectification for fisheye camera model
public static void StereoRectify(InputArray k1, InputArray d1, InputArray k2, InputArray d2, Size imageSize, InputArray r, InputArray tvec, OutputArray r1, OutputArray r2, OutputArray p1, OutputArray p2, OutputArray q, FishEyeCalibrationFlags flags, Size newImageSize = default, double balance = 0, double fovScale = 1)
Parameters
k1InputArrayFirst camera matrix.
d1InputArrayFirst camera distortion parameters.
k2InputArraySecond camera matrix.
d2InputArraySecond camera distortion parameters.
imageSizeSizeSize of the image used for stereo calibration.
rInputArrayRotation matrix between the coordinate systems of the first and the second cameras.
tvecInputArrayTranslation vector between coordinate systems of the cameras.
r1OutputArrayOutput 3x3 rectification transform (rotation matrix) for the first camera.
r2OutputArrayOutput 3x3 rectification transform (rotation matrix) for the second camera.
p1OutputArrayOutput 3x4 projection matrix in the new (rectified) coordinate systems for the first camera.
p2OutputArrayOutput 3x4 projection matrix in the new (rectified) coordinate systems for the second camera.
qOutputArrayOutput 4x4 disparity-to-depth mapping matrix (see reprojectImageTo3D ).
flagsFishEyeCalibrationFlagsOperation flags that may be zero or 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.
newImageSizeSizeNew 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.
balancedoubleSets the new focal length in range between the min focal length and the max focal length.Balance is in range of[0, 1].
fovScaledoubleDivisor for new focal length.
UndistortImage(InputArray, OutputArray, InputArray, InputArray, InputArray?, Size)
Transforms an image to compensate for fisheye lens distortion.
public static void UndistortImage(InputArray distorted, OutputArray undistorted, InputArray k, InputArray d, InputArray? knew = null, Size newSize = default)
Parameters
distortedInputArrayimage with fisheye lens distortion.
undistortedOutputArrayOutput image with compensated fisheye lens distortion.
kInputArrayCamera matrix
dInputArrayInput vector of distortion coefficients (k_1, k_2, k_3, k_4).
knewInputArrayCamera matrix of the distorted image. By default, it is the identity matrix but you may additionally scale and shift the result by using a different matrix.
newSizeSize
UndistortPoints(InputArray, OutputArray, InputArray, InputArray, InputArray?, InputArray?)
Undistorts 2D points using fisheye model
public static void UndistortPoints(InputArray distorted, OutputArray undistorted, InputArray k, InputArray d, InputArray? r = null, InputArray? p = null)
Parameters
distortedInputArrayArray of object points, 1xN/Nx1 2-channel (or vector<Point2f> ), where N is the number of points in the view.
undistortedOutputArrayOutput array of image points, 1xN/Nx1 2-channel, or vector>Point2f> .
kInputArrayCamera matrix
dInputArrayInput vector of distortion coefficients (k_1, k_2, k_3, k_4).
rInputArrayRectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel
pInputArrayNew camera matrix (3x3) or new projection matrix (3x4)