Table of Contents

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

objectPoints IEnumerable<Mat>

vector of vectors of calibration pattern points in the calibration pattern coordinate space.

imagePoints IEnumerable<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.

imageSize Size

Size of the image used only to initialize the intrinsic camera matrix.

k InputOutputArray

Output 3x3 floating-point camera matrix

d InputOutputArray

Output vector of distortion coefficients (k_1, k_2, k_3, k_4).

rvecs IEnumerable<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).

tvecs IEnumerable<Mat>

Output vector of translation vectors estimated for each pattern view.

flags FishEyeCalibrationFlags

Different flags that may be zero or a combination of flag values

criteria TermCriteria?

Termination criteria for the iterative optimization algorithm.

Returns

double

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

undistorted InputArray

Array of object points, 1xN/Nx1 2-channel (or vector<Point2f> ), where N is the number of points in the view.

distorted OutputArray

Output array of image points, 1xN/Nx1 2-channel, or vector<Point2f> .

k InputArray

Camera matrix

d InputArray

Input vector of distortion coefficients

alpha double

The 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

k InputArray

Camera matrix

d InputArray

Input vector of distortion coefficients (k_1, k_2, k_3, k_4).

imageSize Size
r InputArray

Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel

p OutputArray

New camera matrix (3x3) or new projection matrix (3x4)

balance double

Sets the new focal length in range between the min focal length and the max focal length.Balance is in range of[0, 1].

newSize Size
fovScale double

Divisor 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

k InputArray

Camera matrix

d InputArray

Input vector of distortion coefficients (k_1, k_2, k_3, k_4).

r InputArray

Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel

p InputArray

New camera matrix (3x3) or new projection matrix (3x4)

size Size

Undistorted image size.

m1type int

Type of the first output map that can be CV_32FC1 or CV_16SC2 . See convertMaps() for details.

map1 OutputArray

The first output map.

map2 OutputArray

The 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

objectPoints InputArray

Array of object points, 1xN/Nx1 3-channel (or vector<Point3f> ), where N is the number of points in the view.

imagePoints OutputArray

Output array of image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, or vector<Point2f>.

rvec InputArray
tvec InputArray
k InputArray

Camera matrix

d InputArray

Input vector of distortion coefficients

alpha double

The skew coefficient.

jacobian OutputArray

Optional 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

objectPoints IEnumerable<Mat>

Vector of vectors of the calibration pattern points.

imagePoints1 IEnumerable<Mat>

Vector of vectors of the projections of the calibration pattern points, observed by the first camera.

imagePoints2 IEnumerable<Mat>

Vector of vectors of the projections of the calibration pattern points, observed by the second camera.

k1 InputOutputArray

Input/output first camera matrix

d1 InputOutputArray

Input/output vector of distortion coefficients (k_1, k_2, k_3, k_4) of 4 elements.

k2 InputOutputArray

Input/output second camera matrix. The parameter is similar to K1 .

d2 InputOutputArray

Input/output lens distortion coefficients for the second camera. The parameter is similar to D1.

imageSize Size

Size of the image used only to initialize intrinsic camera matrix.

r OutputArray

Output rotation matrix between the 1st and the 2nd camera coordinate systems.

t OutputArray

Output translation vector between the coordinate systems of the cameras.

flags FishEyeCalibrationFlags

Different flags that may be zero or a combination of the FishEyeCalibrationFlags values

criteria TermCriteria?

Termination criteria for the iterative optimization algorithm.

Returns

double

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

k1 InputArray

First camera matrix.

d1 InputArray

First camera distortion parameters.

k2 InputArray

Second camera matrix.

d2 InputArray

Second camera distortion parameters.

imageSize Size

Size of the image used for stereo calibration.

r InputArray

Rotation matrix between the coordinate systems of the first and the second cameras.

tvec InputArray

Translation vector between coordinate systems of the cameras.

r1 OutputArray

Output 3x3 rectification transform (rotation matrix) for the first camera.

r2 OutputArray

Output 3x3 rectification transform (rotation matrix) for the second camera.

p1 OutputArray

Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera.

p2 OutputArray

Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera.

q OutputArray

Output 4x4 disparity-to-depth mapping matrix (see reprojectImageTo3D ).

flags FishEyeCalibrationFlags

Operation 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.

newImageSize Size

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 double

Sets the new focal length in range between the min focal length and the max focal length.Balance is in range of[0, 1].

fovScale double

Divisor 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

distorted InputArray

image with fisheye lens distortion.

undistorted OutputArray

Output image with compensated fisheye lens distortion.

k InputArray

Camera matrix

d InputArray

Input vector of distortion coefficients (k_1, k_2, k_3, k_4).

knew InputArray

Camera 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.

newSize Size

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

distorted InputArray

Array of object points, 1xN/Nx1 2-channel (or vector<Point2f> ), where N is the number of points in the view.

undistorted OutputArray

Output array of image points, 1xN/Nx1 2-channel, or vector>Point2f> .

k InputArray

Camera matrix

d InputArray

Input vector of distortion coefficients (k_1, k_2, k_3, k_4).

r InputArray

Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel

p InputArray

New camera matrix (3x3) or new projection matrix (3x4)