Commit e7b43535 authored by Ilya Lysenkov's avatar Ilya Lysenkov

Added termination criteria as a calibrateCamera() parameter

parent 33bc0895
...@@ -111,11 +111,11 @@ calibrateCamera ...@@ -111,11 +111,11 @@ calibrateCamera
--------------- ---------------
Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern. Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
.. ocv:function:: double calibrateCamera( InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, int flags=0 ) .. ocv:function:: double calibrateCamera( InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, int flags=0, TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, DBL_EPSILON))
.. ocv:pyfunction:: cv2.calibrateCamera(objectPoints, imagePoints, imageSize[, cameraMatrix[, distCoeffs[, rvecs[, tvecs[, flags]]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs .. ocv:pyfunction:: cv2.calibrateCamera(objectPoints, imagePoints, imageSize[, cameraMatrix[, distCoeffs[, rvecs[, tvecs[, flags[, criteria]]]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs
.. ocv:cfunction:: double cvCalibrateCamera2( const CvMat* objectPoints, const CvMat* imagePoints, const CvMat* pointCounts, CvSize imageSize, CvMat* cameraMatrix, CvMat* distCoeffs, CvMat* rvecs=NULL, CvMat* tvecs=NULL, int flags=0 ) .. ocv:cfunction:: double cvCalibrateCamera2( const CvMat* objectPoints, const CvMat* imagePoints, const CvMat* pointCounts, CvSize imageSize, CvMat* cameraMatrix, CvMat* distCoeffs, CvMat* rvecs=NULL, CvMat* tvecs=NULL, int flags=0, CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,DBL_EPSILON)) )
.. ocv:pyoldfunction:: cv.CalibrateCamera2(objectPoints, imagePoints, pointCounts, imageSize, cameraMatrix, distCoeffs, rvecs, tvecs, flags=0)-> None .. ocv:pyoldfunction:: cv.CalibrateCamera2(objectPoints, imagePoints, pointCounts, imageSize, cameraMatrix, distCoeffs, rvecs, tvecs, flags=0)-> None
...@@ -153,6 +153,8 @@ Finds the camera intrinsic and extrinsic parameters from several views of a cali ...@@ -153,6 +153,8 @@ Finds the camera intrinsic and extrinsic parameters from several views of a cali
* **CV_CALIB_RATIONAL_MODEL** Coefficients k4, k5, and k6 are enabled. To provide the backward compatibility, this extra flag should be explicitly specified to make the calibration function use the rational model and return 8 coefficients. If the flag is not set, the function computes and returns only 5 distortion coefficients. * **CV_CALIB_RATIONAL_MODEL** Coefficients k4, k5, and k6 are enabled. To provide the backward compatibility, this extra flag should be explicitly specified to make the calibration function use the rational model and return 8 coefficients. If the flag is not set, the function computes and returns only 5 distortion coefficients.
:param criteria: Termination criteria for the iterative optimization algorithm.
The function estimates the intrinsic camera The function estimates the intrinsic camera
parameters and extrinsic parameters for each of the views. The algorithm is based on [Zhang2000] and [BoughuetMCT]. The coordinates of 3D object points and their corresponding 2D projections parameters and extrinsic parameters for each of the views. The algorithm is based on [Zhang2000] and [BoughuetMCT]. The coordinates of 3D object points and their corresponding 2D projections
in each view must be specified. That may be achieved by using an in each view must be specified. That may be achieved by using an
......
...@@ -246,7 +246,9 @@ CVAPI(double) cvCalibrateCamera2( const CvMat* object_points, ...@@ -246,7 +246,9 @@ CVAPI(double) cvCalibrateCamera2( const CvMat* object_points,
CvMat* distortion_coeffs, CvMat* distortion_coeffs,
CvMat* rotation_vectors CV_DEFAULT(NULL), CvMat* rotation_vectors CV_DEFAULT(NULL),
CvMat* translation_vectors CV_DEFAULT(NULL), CvMat* translation_vectors CV_DEFAULT(NULL),
int flags CV_DEFAULT(0) ); int flags CV_DEFAULT(0),
CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,DBL_EPSILON)) );
/* Computes various useful characteristics of the camera from the data computed by /* Computes various useful characteristics of the camera from the data computed by
cvCalibrateCamera2 */ cvCalibrateCamera2 */
...@@ -579,7 +581,8 @@ CV_EXPORTS_W double calibrateCamera( InputArrayOfArrays objectPoints, ...@@ -579,7 +581,8 @@ CV_EXPORTS_W double calibrateCamera( InputArrayOfArrays objectPoints,
CV_OUT InputOutputArray cameraMatrix, CV_OUT InputOutputArray cameraMatrix,
CV_OUT InputOutputArray distCoeffs, CV_OUT InputOutputArray distCoeffs,
OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
int flags=0 ); int flags=0, TermCriteria criteria = TermCriteria(
TermCriteria::COUNT+TermCriteria::EPS, 30, DBL_EPSILON) );
//! computes several useful camera characteristics from the camera matrix, camera frame resolution and the physical sensor size. //! computes several useful camera characteristics from the camera matrix, camera frame resolution and the physical sensor size.
CV_EXPORTS_W void calibrationMatrixValues( InputArray cameraMatrix, CV_EXPORTS_W void calibrationMatrixValues( InputArray cameraMatrix,
......
...@@ -1452,7 +1452,7 @@ CV_IMPL void cvInitIntrinsicParams2D( const CvMat* objectPoints, ...@@ -1452,7 +1452,7 @@ CV_IMPL void cvInitIntrinsicParams2D( const CvMat* objectPoints,
CV_IMPL double cvCalibrateCamera2( const CvMat* objectPoints, CV_IMPL double cvCalibrateCamera2( const CvMat* objectPoints,
const CvMat* imagePoints, const CvMat* npoints, const CvMat* imagePoints, const CvMat* npoints,
CvSize imageSize, CvMat* cameraMatrix, CvMat* distCoeffs, CvSize imageSize, CvMat* cameraMatrix, CvMat* distCoeffs,
CvMat* rvecs, CvMat* tvecs, int flags ) CvMat* rvecs, CvMat* tvecs, int flags, CvTermCriteria termCrit )
{ {
const int NINTRINSIC = 12; const int NINTRINSIC = 12;
Ptr<CvMat> matM, _m, _Ji, _Je, _err; Ptr<CvMat> matM, _m, _Ji, _Je, _err;
...@@ -1600,7 +1600,7 @@ CV_IMPL double cvCalibrateCamera2( const CvMat* objectPoints, ...@@ -1600,7 +1600,7 @@ CV_IMPL double cvCalibrateCamera2( const CvMat* objectPoints,
cvInitIntrinsicParams2D( matM, _m, npoints, imageSize, &matA, aspectRatio ); cvInitIntrinsicParams2D( matM, _m, npoints, imageSize, &matA, aspectRatio );
} }
solver.init( nparams, 0, cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,DBL_EPSILON) ); solver.init( nparams, 0, termCrit );
{ {
double* param = solver.param->data.db; double* param = solver.param->data.db;
...@@ -3396,7 +3396,7 @@ cv::Mat cv::initCameraMatrix2D( InputArrayOfArrays objectPoints, ...@@ -3396,7 +3396,7 @@ cv::Mat cv::initCameraMatrix2D( InputArrayOfArrays objectPoints,
double cv::calibrateCamera( InputArrayOfArrays _objectPoints, double cv::calibrateCamera( InputArrayOfArrays _objectPoints,
InputArrayOfArrays _imagePoints, InputArrayOfArrays _imagePoints,
Size imageSize, InputOutputArray _cameraMatrix, InputOutputArray _distCoeffs, Size imageSize, InputOutputArray _cameraMatrix, InputOutputArray _distCoeffs,
OutputArrayOfArrays _rvecs, OutputArrayOfArrays _tvecs, int flags ) OutputArrayOfArrays _rvecs, OutputArrayOfArrays _tvecs, int flags, TermCriteria criteria )
{ {
int rtype = CV_64F; int rtype = CV_64F;
Mat cameraMatrix = _cameraMatrix.getMat(); Mat cameraMatrix = _cameraMatrix.getMat();
...@@ -3418,7 +3418,7 @@ double cv::calibrateCamera( InputArrayOfArrays _objectPoints, ...@@ -3418,7 +3418,7 @@ double cv::calibrateCamera( InputArrayOfArrays _objectPoints,
double reprojErr = cvCalibrateCamera2(&c_objPt, &c_imgPt, &c_npoints, imageSize, double reprojErr = cvCalibrateCamera2(&c_objPt, &c_imgPt, &c_npoints, imageSize,
&c_cameraMatrix, &c_distCoeffs, &c_rvecM, &c_cameraMatrix, &c_distCoeffs, &c_rvecM,
&c_tvecM, flags ); &c_tvecM, flags, criteria );
bool rvecs_needed = _rvecs.needed(), tvecs_needed = _tvecs.needed(); bool rvecs_needed = _rvecs.needed(), tvecs_needed = _tvecs.needed();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment