diff --git a/modules/aruco/include/opencv2/aruco.hpp b/modules/aruco/include/opencv2/aruco.hpp index b650ec597..5408a236d 100644 --- a/modules/aruco/include/opencv2/aruco.hpp +++ b/modules/aruco/include/opencv2/aruco.hpp @@ -474,7 +474,7 @@ void _drawPlanarBoardImpl(Board *board, Size outSize, OutputArray img, * @brief Calibrate a camera using aruco markers * * @param corners vector of detected marker corners in all frames. - * The corners should have the same format returned by detectMarkers (@sa detectMarkers). + * The corners should have the same format returned by detectMarkers (see #detectMarkers). * @param ids list of identifiers for each marker in corners * @param counter number of markers in each frame so that corners and ids can be split * @param board Marker Board layout @@ -491,20 +491,38 @@ void _drawPlanarBoardImpl(Board *board, Size outSize, OutputArray img, * from the model coordinate space (in which object points are specified) to the world coordinate * space, that is, a real position of the board pattern in the k-th pattern view (k=0.. *M* -1). * @param tvecs Output vector of translation vectors estimated for each pattern view. - * @param flags flags Different flags for the calibration process (@sa calibrateCamera) + * @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters. + * Order of deviations values: + * \f$(f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3, + * s_4, \tau_x, \tau_y)\f$ If one of parameters is not estimated, it's deviation is equals to zero. + * @param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters. + * Order of deviations values: \f$(R_1, T_1, \dotsc , R_M, T_M)\f$ where M is number of pattern views, + * \f$R_i, T_i\f$ are concatenated 1x3 vectors. + * @param perViewErrors Output vector of average re-projection errors estimated for each pattern view. + * @param flags flags Different flags for the calibration process (see #calibrateCamera for details). * @param criteria Termination criteria for the iterative optimization algorithm. * * This function calibrates a camera using an Aruco Board. The function receives a list of * detected markers from several views of the Board. The process is similar to the chessboard * calibration in calibrateCamera(). The function returns the final re-projection error. */ -CV_EXPORTS_W double calibrateCameraAruco( +CV_EXPORTS_AS(calibrateCameraArucoExtended) double calibrateCameraAruco( InputArrayOfArrays corners, InputArray ids, InputArray counter, Ptr &board, Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs, - OutputArrayOfArrays rvecs = noArray(), OutputArrayOfArrays tvecs = noArray(), int flags = 0, + OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, + OutputArray stdDeviationsIntrinsics = noArray(), OutputArray stdDeviationsExtrinsics = noArray(), + OutputArray perViewErrors = noArray(), int flags = 0, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON)); +/** @brief It's the same function as #calibrateCameraAruco but without calibration error estimation. + */ +CV_EXPORTS_W double calibrateCameraAruco( + InputArrayOfArrays corners, InputArray ids, InputArray counter, Ptr &board, + Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs, + OutputArrayOfArrays rvecs = noArray(), OutputArrayOfArrays tvecs = noArray(), int flags = 0, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON)); + //! @} } diff --git a/modules/aruco/include/opencv2/aruco/charuco.hpp b/modules/aruco/include/opencv2/aruco/charuco.hpp index dd7f15ec3..73c10cba6 100644 --- a/modules/aruco/include/opencv2/aruco/charuco.hpp +++ b/modules/aruco/include/opencv2/aruco/charuco.hpp @@ -223,19 +223,36 @@ CV_EXPORTS_W void drawDetectedCornersCharuco(InputOutputArray image, InputArray * from the model coordinate space (in which object points are specified) to the world coordinate * space, that is, a real position of the board pattern in the k-th pattern view (k=0.. *M* -1). * @param tvecs Output vector of translation vectors estimated for each pattern view. - * @param flags flags Different flags for the calibration process (@sa calibrateCamera) + * @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters. + * Order of deviations values: + * \f$(f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3, + * s_4, \tau_x, \tau_y)\f$ If one of parameters is not estimated, it's deviation is equals to zero. + * @param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters. + * Order of deviations values: \f$(R_1, T_1, \dotsc , R_M, T_M)\f$ where M is number of pattern views, + * \f$R_i, T_i\f$ are concatenated 1x3 vectors. + * @param perViewErrors Output vector of average re-projection errors estimated for each pattern view. + * @param flags flags Different flags for the calibration process (see #calibrateCamera for details). * @param criteria Termination criteria for the iterative optimization algorithm. * * This function calibrates a camera using a set of corners of a Charuco Board. The function * receives a list of detected corners and its identifiers from several views of the Board. * The function returns the final re-projection error. */ -CV_EXPORTS_W double calibrateCameraCharuco( +CV_EXPORTS_AS(calibrateCameraCharucoExtended) double calibrateCameraCharuco( InputArrayOfArrays charucoCorners, InputArrayOfArrays charucoIds, Ptr &board, Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs, - OutputArrayOfArrays rvecs = noArray(), OutputArrayOfArrays tvecs = noArray(), int flags = 0, + OutputArrayOfArrays rvecs = noArray(), OutputArrayOfArrays tvecs = noArray(), + OutputArray stdDeviationsIntrinsics = noArray(), OutputArray stdDeviationsExtrinsics = noArray(), + OutputArray perViewErrors = noArray(), int flags = 0, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON)); +/** @brief It's the same function as #calibrateCameraCharuco but without calibration error estimation. +*/ +CV_EXPORTS_W double calibrateCameraCharuco( + InputArrayOfArrays charucoCorners, InputArrayOfArrays charucoIds, Ptr &board, + Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs, + OutputArrayOfArrays rvecs = noArray(), OutputArrayOfArrays tvecs = noArray(), int flags = 0, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON)); diff --git a/modules/aruco/src/aruco.cpp b/modules/aruco/src/aruco.cpp index 91a236f19..69e366661 100644 --- a/modules/aruco/src/aruco.cpp +++ b/modules/aruco/src/aruco.cpp @@ -1560,11 +1560,15 @@ void drawPlanarBoard(Ptr &_board, Size outSize, OutputArray _img, int mar /** - */ + */ double calibrateCameraAruco(InputArrayOfArrays _corners, InputArray _ids, InputArray _counter, Ptr &board, Size imageSize, InputOutputArray _cameraMatrix, InputOutputArray _distCoeffs, OutputArrayOfArrays _rvecs, - OutputArrayOfArrays _tvecs, int flags, TermCriteria criteria) { + OutputArrayOfArrays _tvecs, + OutputArray _stdDeviationsIntrinsics, + OutputArray _stdDeviationsExtrinsics, + OutputArray _perViewErrors, + int flags, TermCriteria criteria) { // for each frame, get properly processed imagePoints and objectPoints for the calibrateCamera // function @@ -1595,7 +1599,20 @@ double calibrateCameraAruco(InputArrayOfArrays _corners, InputArray _ids, InputA } return calibrateCamera(processedObjectPoints, processedImagePoints, imageSize, _cameraMatrix, - _distCoeffs, _rvecs, _tvecs, flags, criteria); + _distCoeffs, _rvecs, _tvecs, _stdDeviationsIntrinsics, _stdDeviationsExtrinsics, + _perViewErrors, flags, criteria); +} + + + +/** + */ +double calibrateCameraAruco(InputArrayOfArrays _corners, InputArray _ids, InputArray _counter, + Ptr &board, Size imageSize, InputOutputArray _cameraMatrix, + InputOutputArray _distCoeffs, OutputArrayOfArrays _rvecs, + OutputArrayOfArrays _tvecs, int flags, TermCriteria criteria) { + return calibrateCameraAruco(_corners, _ids, _counter, board, imageSize, _cameraMatrix, _distCoeffs, _rvecs, _tvecs, + noArray(), noArray(), noArray(), flags, criteria); } diff --git a/modules/aruco/src/charuco.cpp b/modules/aruco/src/charuco.cpp index dc5bb3828..0a7d961af 100644 --- a/modules/aruco/src/charuco.cpp +++ b/modules/aruco/src/charuco.cpp @@ -713,8 +713,11 @@ bool estimatePoseCharucoBoard(InputArray _charucoCorners, InputArray _charucoIds double calibrateCameraCharuco(InputArrayOfArrays _charucoCorners, InputArrayOfArrays _charucoIds, Ptr &_board, Size imageSize, InputOutputArray _cameraMatrix, InputOutputArray _distCoeffs, - OutputArrayOfArrays _rvecs, OutputArrayOfArrays _tvecs, int flags, - TermCriteria criteria) { + OutputArrayOfArrays _rvecs, OutputArrayOfArrays _tvecs, + OutputArray _stdDeviationsIntrinsics, + OutputArray _stdDeviationsExtrinsics, + OutputArray _perViewErrors, + int flags, TermCriteria criteria) { CV_Assert(_charucoIds.total() > 0 && (_charucoIds.total() == _charucoCorners.total())); @@ -734,11 +737,24 @@ double calibrateCameraCharuco(InputArrayOfArrays _charucoCorners, InputArrayOfAr } return calibrateCamera(allObjPoints, _charucoCorners, imageSize, _cameraMatrix, _distCoeffs, - _rvecs, _tvecs, flags, criteria); + _rvecs, _tvecs, _stdDeviationsIntrinsics, _stdDeviationsExtrinsics, + _perViewErrors, flags, criteria); } +/** + */ +double calibrateCameraCharuco(InputArrayOfArrays _charucoCorners, InputArrayOfArrays _charucoIds, + Ptr &_board, Size imageSize, + InputOutputArray _cameraMatrix, InputOutputArray _distCoeffs, + OutputArrayOfArrays _rvecs, OutputArrayOfArrays _tvecs, int flags, + TermCriteria criteria) { + return calibrateCameraCharuco(_charucoCorners, _charucoIds, _board, imageSize, _cameraMatrix, _distCoeffs, _rvecs, + _tvecs, noArray(), noArray(), noArray(), flags, criteria); +} + + /** */ void detectCharucoDiamond(InputArray _image, InputArrayOfArrays _markerCorners,