Class Fisheye
Fisheye Camera model
public static class Fisheye
- Inheritance
-
Fisheye
- Inherited Members
Methods
Calibrate(IInputArray, IInputArray, Size, IInputOutputArray, IInputOutputArray, IOutputArray, IOutputArray, CalibrationFlag, MCvTermCriteria)
Performs camera calibration.
public static double Calibrate(IInputArray objectPoints, IInputArray imagePoints, Size imageSize, IInputOutputArray K, IInputOutputArray D, IOutputArray rvecs, IOutputArray tvecs, Fisheye.CalibrationFlag flags, MCvTermCriteria criteria)
Parameters
objectPoints
IInputArrayvector of vectors of calibration pattern points in the calibration pattern coordinate space.
imagePoints
IInputArrayvector 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
SizeSize of the image used only to initialize the intrinsic camera matrix.
K
IInputOutputArrayOutput 3x3 floating-point camera matrix. If UseIntrisicGuess is specified, some or all of fx, fy, cx, cy must be initialized before calling the function.
D
IInputOutputArrayOutput vector of distortion coefficients (k1,k2,k3,k4).
rvecs
IOutputArrayOutput 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
IOutputArrayOutput vector of translation vectors estimated for each pattern view.
flags
Fisheye.CalibrationFlagDifferent flags
criteria
MCvTermCriteriaTermination criteria for the iterative optimization algorithm.
Returns
- double
The calibration error
DistortPoints(IInputArray, IOutputArray, IInputArray, IInputArray, double)
Distorts 2D points using fisheye model.
public static void DistortPoints(IInputArray undistored, IOutputArray distorted, IInputArray K, IInputArray D, double alpha = 0)
Parameters
undistored
IInputArrayArray of object points, 1xN/Nx1 2-channel (or vector<Point2f> ), where N is the number of points in the view.
distorted
IOutputArrayOutput array of image points, 1xN/Nx1 2-channel, or vector<Point2f> .
K
IInputArrayCamera matrix
D
IInputArrayInput vector of distortion coefficients (k1,k2,k3,k4).
alpha
doubleThe skew coefficient.
EstimateNewCameraMatrixForUndistortRectify(IInputArray, IInputArray, Size, IInputArray, IOutputArray, double, Size, double)
Estimates new camera matrix for undistortion or rectification.
public static void EstimateNewCameraMatrixForUndistortRectify(IInputArray K, IInputArray D, Size imageSize, IInputArray R, IOutputArray P, double balance = 0, Size newSize = default, double fovScale = 1)
Parameters
K
IInputArrayCamera matrix
D
IInputArrayInput vector of distortion coefficients (k1,k2,k3,k4).
imageSize
SizeSize of the image
R
IInputArrayRectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel
P
IOutputArrayNew camera matrix (3x3) or new projection matrix (3x4)
balance
doubleSets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1]
newSize
Sizethe new size
fovScale
doubleDivisor for new focal length.
InitUndistortRectifyMap(IInputArray, IInputArray, IInputArray, IInputArray, Size, DepthType, int, IOutputArray, IOutputArray)
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(IInputArray K, IInputArray D, IInputArray R, IInputArray P, Size size, DepthType depthType, int channels, IOutputArray map1, IOutputArray map2)
Parameters
K
IInputArrayCamera matrix
D
IInputArrayInput vector of distortion coefficients (k1,k2,k3,k4).
R
IInputArrayRectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel
P
IInputArrayNew camera matrix (3x3) or new projection matrix (3x4)
size
SizeUndistorted image size.
depthType
DepthTypeDepth type of the first output map. (The combination with
channels
can be one of CV_32FC1 or CV_16SC2)channels
intNumber of channels of the first output map. (The combination with
depthType
can be one of CV_32FC1 or CV_16SC2)map1
IOutputArrayThe first output map.
map2
IOutputArrayThe second output map.
ProjectPoints(IInputArray, IOutputArray, IInputArray, IInputArray, IInputArray, IInputArray, double, IOutputArray)
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(IInputArray objectPoints, IOutputArray imagePoints, IInputArray rvec, IInputArray tvec, IInputArray K, IInputArray D, double alpha = 0, IOutputArray jacobian = null)
Parameters
objectPoints
IInputArrayArray of object points, 1xN/Nx1 3-channel (or vector<Point3f> ), where N is the number of points in the view.
imagePoints
IOutputArrayOutput array of image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, or vector<Point2f>.
rvec
IInputArrayrotation vector
tvec
IInputArraytranslation vector
K
IInputArrayCamera matrix
D
IInputArrayInput vector of distortion coefficients (k1,k2,k3,k4).
alpha
doubleThe skew coefficient.
jacobian
IOutputArrayOptional 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(IInputArray, IInputArray, IInputArray, IInputOutputArray, IInputOutputArray, IInputOutputArray, IInputOutputArray, Size, IOutputArray, IOutputArray, CalibrationFlag, MCvTermCriteria)
Performs stereo calibration.
public static double StereoCalibrate(IInputArray objectPoints, IInputArray imagePoints1, IInputArray imagePoints2, IInputOutputArray K1, IInputOutputArray D1, IInputOutputArray K2, IInputOutputArray D2, Size imageSize, IOutputArray R, IOutputArray T, Fisheye.CalibrationFlag flags, MCvTermCriteria criteria)
Parameters
objectPoints
IInputArrayVector of vectors of the calibration pattern points.
imagePoints1
IInputArrayVector of vectors of the projections of the calibration pattern points, observed by the first camera.
imagePoints2
IInputArrayVector of vectors of the projections of the calibration pattern points, observed by the second camera.
K1
IInputOutputArrayInput/output first camera matrix.If FixIntrinsic is specified, some or all of the matrix components must be initialized.
D1
IInputOutputArrayInput/output vector of distortion coefficients (k1,k2,k3,k4) of 4 elements.
K2
IInputOutputArrayInput/output second camera matrix. The parameter is similar to
K1
D2
IInputOutputArrayInput/output lens distortion coefficients for the second camera. The parameter is similar to
D1
imageSize
SizeSize of the image used only to initialize intrinsic camera matrix.
R
IOutputArrayOutput rotation matrix between the 1st and the 2nd camera coordinate systems.
T
IOutputArrayOutput translation vector between the coordinate systems of the cameras.
flags
Fisheye.CalibrationFlagFish eye calibration flags
criteria
MCvTermCriteriaTermination criteria for the iterative optimization algorithm.
Returns
- double
The calibration error
StereoRectify(IInputArray, IInputArray, IInputArray, IInputArray, Size, IInputArray, IInputArray, IOutputArray, IOutputArray, IOutputArray, IOutputArray, IOutputArray, int, Size, double, double)
Stereo rectification for fisheye camera model.
public static void StereoRectify(IInputArray K1, IInputArray D1, IInputArray K2, IInputArray D2, Size imageSize, IInputArray R, IInputArray tvec, IOutputArray R1, IOutputArray R2, IOutputArray P1, IOutputArray P2, IOutputArray Q, int flags, Size newImageSize = default, double balance = 0, double fovScale = 1)
Parameters
K1
IInputArrayFirst camera matrix.
D1
IInputArrayFirst camera distortion parameters.
K2
IInputArraySecond camera matrix.
D2
IInputArraySecond camera distortion parameters.
imageSize
SizeSize of the image used for stereo calibration.
R
IInputArrayRotation matrix between the coordinate systems of the first and the second cameras.
tvec
IInputArrayTranslation vector between coordinate systems of the cameras.
R1
IOutputArrayOutput 3x3 rectification transform (rotation matrix) for the first camera.
R2
IOutputArrayOutput 3x3 rectification transform (rotation matrix) for the second camera.
P1
IOutputArrayOutput 3x4 projection matrix in the new (rectified) coordinate systems for the first camera.
P2
IOutputArrayOutput 3x4 projection matrix in the new (rectified) coordinate systems for the second camera.
Q
IOutputArrayOutput 4×4 disparity-to-depth mapping matrix (see reprojectImageTo3D ).
flags
intOperation flags that may be zero or ZeroDisparity . 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
SizeNew image resolution after rectification. The same size should be passed to initUndistortRectifyMap. When (0,0) is passed (default), it is set to the original imageSize . Setting it to larger value can help you preserve details in the original image, especially when there is a big radial distortion.
balance
doubleSets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1].
fovScale
doubleDivisor for new focal length.
UndistortImage(IInputArray, IOutputArray, IInputArray, IInputArray, IInputArray, Size)
Transforms an image to compensate for fisheye lens distortion. The function is simply a combination of fisheye::initUndistortRectifyMap (with unity R ) and remap (with bilinear interpolation).
public static void UndistortImage(IInputArray distorted, IOutputArray undistored, IInputArray K, IInputArray D, IInputArray Knew = null, Size newSize = default)
Parameters
distorted
IInputArrayImage with fisheye lens distortion.
undistored
IOutputArrayOutput image with compensated fisheye lens distortion.
K
IInputArrayCamera matrix
D
IInputArrayInput vector of distortion coefficients (k1,k2,k3,k4).
Knew
IInputArrayCamera 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
SizeThe function transforms an image to compensate radial and tangential lens distortion.
UndistortPoints(IInputArray, IOutputArray, IInputArray, IInputArray, IInputArray, IInputArray)
Transforms an image to compensate for fisheye lens distortion.
public static void UndistortPoints(IInputArray distorted, IOutputArray undistorted, IInputArray K, IInputArray D, IInputArray R = null, IInputArray P = null)
Parameters
distorted
IInputArrayArray of object points, 1xN/Nx1 2-channel (or vector<Point2f> ), where N is the number of points in the view.
undistorted
IOutputArrayOutput array of image points, 1xN/Nx1 2-channel, or vector<Point2f>.
K
IInputArrayCamera matrix
D
IInputArrayInput vector of distortion coefficients (k1,k2,k3,k4).
R
IInputArrayRectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel
P
IInputArrayNew camera matrix (3x3) or new projection matrix (3x4)