Method CalibrateCamera
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
CalibrateCamera(IEnumerable<Mat>, IEnumerable<Mat>, Size, InputOutputArray, InputOutputArray, out Mat[], out Mat[], CalibrationFlags, TermCriteria?)
finds intrinsic and extrinsic camera parameters from several fews of a known calibration pattern.
public static double CalibrateCamera(IEnumerable<Mat> objectPoints, IEnumerable<Mat> imagePoints, Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs, out Mat[] rvecs, out Mat[] tvecs, CalibrationFlags flags = CalibrationFlags.None, TermCriteria? criteria = null)
Parameters
objectPointsIEnumerable<Mat>In the new interface it is a vector of vectors of calibration pattern points in the calibration pattern coordinate space. The outer vector contains as many elements as the number of the pattern views. If the same calibration pattern is shown in each view and it is fully visible, all the vectors will be the same. Although, it is possible to use partially occluded patterns, or even different patterns in different views. Then, the vectors will be different. The points are 3D, but since they are in a pattern coordinate system, then, if the rig is planar, it may make sense to put the model to a XY coordinate plane so that Z-coordinate of each input object point is 0. In the old interface all the vectors of object points from different views are concatenated together.
imagePointsIEnumerable<Mat>In the new interface it is a vector of vectors of the projections of calibration pattern points. imagePoints.Count() and objectPoints.Count() and imagePoints[i].Count() must be equal to objectPoints[i].Count() for each i.
imageSizeSizeSize of the image used only to initialize the intrinsic camera matrix.
cameraMatrixInputOutputArrayInput/output 3x3 floating-point camera matrix. If CV_CALIB_USE_INTRINSIC_GUESS and/or CV_CALIB_FIX_ASPECT_RATIO are specified, some or all of fx, fy, cx, cy must be initialized before calling the function.
distCoeffsInputOutputArrayInput/output vector of distortion coefficients (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements.
rvecsMat[]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)
tvecsMat[]Output vector of translation vectors estimated for each pattern view.
flagsCalibrationFlagsDifferent flags that may be zero or a combination of the CalibrationFlag values
criteriaTermCriteria?Termination criteria for the iterative optimization algorithm.
Returns
- double
Root mean square (RMS) re-projection error. A value below 1.0 is generally considered acceptable for a good calibration.
CalibrateCamera(IEnumerable<IEnumerable<Point3f>>, IEnumerable<IEnumerable<Point2f>>, Size, double[,], double[], out Vec3d[], out Vec3d[], CalibrationFlags, TermCriteria?)
finds intrinsic and extrinsic camera parameters from several fews of a known calibration pattern.
public static double CalibrateCamera(IEnumerable<IEnumerable<Point3f>> objectPoints, IEnumerable<IEnumerable<Point2f>> imagePoints, Size imageSize, double[,] cameraMatrix, double[] distCoeffs, out Vec3d[] rvecs, out Vec3d[] tvecs, CalibrationFlags flags = CalibrationFlags.None, TermCriteria? criteria = null)
Parameters
objectPointsIEnumerable<IEnumerable<Point3f>>In the new interface it is a vector of vectors of calibration pattern points in the calibration pattern coordinate space. The outer vector contains as many elements as the number of the pattern views. If the same calibration pattern is shown in each view and it is fully visible, all the vectors will be the same. Although, it is possible to use partially occluded patterns, or even different patterns in different views. Then, the vectors will be different. The points are 3D, but since they are in a pattern coordinate system, then, if the rig is planar, it may make sense to put the model to a XY coordinate plane so that Z-coordinate of each input object point is 0. In the old interface all the vectors of object points from different views are concatenated together.
imagePointsIEnumerable<IEnumerable<Point2f>>In the new interface it is a vector of vectors of the projections of calibration pattern points. imagePoints.Count() and objectPoints.Count() and imagePoints[i].Count() must be equal to objectPoints[i].Count() for each i.
imageSizeSizeSize of the image used only to initialize the intrinsic camera matrix.
cameraMatrixdouble[,]Input/output 3x3 floating-point camera matrix. If CV_CALIB_USE_INTRINSIC_GUESS and/or CV_CALIB_FIX_ASPECT_RATIO are specified, some or all of fx, fy, cx, cy must be initialized before calling the function.
distCoeffsdouble[]Input/output vector of distortion coefficients (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements.
rvecsVec3d[]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)
tvecsVec3d[]Output vector of translation vectors estimated for each pattern view.
flagsCalibrationFlagsDifferent flags that may be zero or a combination of the CalibrationFlag values
criteriaTermCriteria?Termination criteria for the iterative optimization algorithm.
Returns
- double
Root mean square (RMS) re-projection error. A value below 1.0 is generally considered acceptable for a good calibration.