Skip to content

Commit 4d96b1f

Browse files
author
AleksandrPanov
committed
move testCharucoCornersCollinear to CharucoBoard
move ArucoTutorial tests to new cpp file move estimatePoseBoard() to board class removed aruco_detector add matchImagePoints add getters to CharucoBoard
1 parent c4027ab commit 4d96b1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+751
-42023
lines changed

modules/aruco/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set(the_description "ArUco Marker Detection")
2-
ocv_define_module(aruco opencv_core opencv_imgproc opencv_calib3d WRAP python java objc js)
2+
ocv_define_module(aruco opencv_core opencv_imgproc opencv_calib3d opencv_objdetect WRAP python java objc js)
33
ocv_include_directories(${CMAKE_CURRENT_BINARY_DIR})
44

55
ocv_add_testdata(samples/ contrib/aruco

modules/aruco/include/opencv2/aruco.hpp

Lines changed: 124 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
// This file is part of OpenCV project.
22
// It is subject to the license terms in the LICENSE file found in the top-level directory
33
// of this distribution and at http://opencv.org/license.html
4-
#ifndef __OPENCV_ARUCO_HPP__
5-
#define __OPENCV_ARUCO_HPP__
4+
#ifndef OPENCV_ARUCO_HPP
5+
#define OPENCV_ARUCO_HPP
66

7-
#include "opencv2/aruco_detector.hpp"
8-
#include "opencv2/aruco/aruco_calib_pose.hpp"
7+
#include "opencv2/objdetect/aruco_detector.hpp"
8+
#include "opencv2/aruco/aruco_calib.hpp"
99

1010
namespace cv {
1111
namespace aruco {
1212

1313

1414
/**
15-
@deprecated Use class ArucoDetector
15+
@deprecated Use class ArucoDetector::detectMarkers
1616
*/
1717
CV_EXPORTS_W void detectMarkers(InputArray image, const Ptr<Dictionary> &dictionary, OutputArrayOfArrays corners,
1818
OutputArray ids, const Ptr<DetectorParameters> &parameters = DetectorParameters::create(),
1919
OutputArrayOfArrays rejectedImgPoints = noArray());
2020

2121
/**
22-
@deprecated Use class ArucoDetector
22+
@deprecated Use class ArucoDetector::refineDetectedMarkers
2323
*/
2424
CV_EXPORTS_W void refineDetectedMarkers(InputArray image,const Ptr<Board> &board,
2525
InputOutputArrayOfArrays detectedCorners,
@@ -29,6 +29,124 @@ CV_EXPORTS_W void refineDetectedMarkers(InputArray image,const Ptr<Board> &boar
2929
bool checkAllOrders = true, OutputArray recoveredIdxs = noArray(),
3030
const Ptr<DetectorParameters> &parameters = DetectorParameters::create());
3131

32+
/**
33+
@deprecated Use Board::draw
34+
*/
35+
CV_EXPORTS_W void drawPlanarBoard(const Ptr<Board> &board, Size outSize, OutputArray img, int marginSize,
36+
int borderBits);
37+
38+
/**
39+
@deprecated Use Board::matchImagePoints
40+
*/
41+
CV_EXPORTS_W void getBoardObjectAndImagePoints(const Ptr<Board> &board, InputArrayOfArrays detectedCorners,
42+
InputArray detectedIds, OutputArray objPoints, OutputArray imgPoints);
43+
44+
45+
/**
46+
* @brief Pose estimation for a board of markers
47+
*
48+
* @param corners vector of already detected markers corners. For each marker, its four corners
49+
* are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers, the
50+
* dimensions of this array should be Nx4. The order of the corners should be clockwise.
51+
* @param ids list of identifiers for each marker in corners
52+
* @param board layout of markers in the board. The layout is composed by the marker identifiers
53+
* and the positions of each marker corner in the board reference system.
54+
* @param cameraMatrix input 3x3 floating-point camera matrix
55+
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
56+
* @param distCoeffs vector of distortion coefficients
57+
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
58+
* @param rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
59+
* (see cv::Rodrigues). Used as initial guess if not empty.
60+
* @param tvec Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.
61+
* @param useExtrinsicGuess defines whether initial guess for \b rvec and \b tvec will be used or not.
62+
* Used as initial guess if not empty.
63+
*
64+
* This function receives the detected markers and returns the pose of a marker board composed
65+
* by those markers.
66+
* A Board of marker has a single world coordinate system which is defined by the board layout.
67+
* The returned transformation is the one that transforms points from the board coordinate system
68+
* to the camera coordinate system.
69+
* Input markers that are not included in the board layout are ignored.
70+
* The function returns the number of markers from the input employed for the board pose estimation.
71+
* Note that returning a 0 means the pose has not been estimated.
72+
* @sa use cv::drawFrameAxes to get world coordinate system axis for object points
73+
*/
74+
CV_EXPORTS_W int estimatePoseBoard(InputArrayOfArrays corners, InputArray ids, const Ptr<Board> &board,
75+
InputArray cameraMatrix, InputArray distCoeffs, InputOutputArray rvec,
76+
InputOutputArray tvec, bool useExtrinsicGuess = false);
77+
78+
/**
79+
* @brief Pose estimation for a ChArUco board given some of their corners
80+
* @param charucoCorners vector of detected charuco corners
81+
* @param charucoIds list of identifiers for each corner in charucoCorners
82+
* @param board layout of ChArUco board.
83+
* @param cameraMatrix input 3x3 floating-point camera matrix
84+
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
85+
* @param distCoeffs vector of distortion coefficients
86+
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
87+
* @param rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
88+
* (see cv::Rodrigues).
89+
* @param tvec Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.
90+
* @param useExtrinsicGuess defines whether initial guess for \b rvec and \b tvec will be used or not.
91+
*
92+
* This function estimates a Charuco board pose from some detected corners.
93+
* The function checks if the input corners are enough and valid to perform pose estimation.
94+
* If pose estimation is valid, returns true, else returns false.
95+
* @sa use cv::drawFrameAxes to get world coordinate system axis for object points
96+
*/
97+
CV_EXPORTS_W bool estimatePoseCharucoBoard(InputArray charucoCorners, InputArray charucoIds,
98+
const Ptr<CharucoBoard> &board, InputArray cameraMatrix,
99+
InputArray distCoeffs, InputOutputArray rvec,
100+
InputOutputArray tvec, bool useExtrinsicGuess = false);
101+
102+
/**
103+
* @brief Pose estimation for single markers
104+
*
105+
* @param corners vector of already detected markers corners. For each marker, its four corners
106+
* are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
107+
* the dimensions of this array should be Nx4. The order of the corners should be clockwise.
108+
* @sa detectMarkers
109+
* @param markerLength the length of the markers' side. The returning translation vectors will
110+
* be in the same unit. Normally, unit is meters.
111+
* @param cameraMatrix input 3x3 floating-point camera matrix
112+
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
113+
* @param distCoeffs vector of distortion coefficients
114+
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
115+
* @param rvecs array of output rotation vectors (@sa Rodrigues) (e.g. std::vector<cv::Vec3d>).
116+
* Each element in rvecs corresponds to the specific marker in imgPoints.
117+
* @param tvecs array of output translation vectors (e.g. std::vector<cv::Vec3d>).
118+
* Each element in tvecs corresponds to the specific marker in imgPoints.
119+
* @param objPoints array of object points of all the marker corners
120+
* @param estimateParameters set the origin of coordinate system and the coordinates of the four corners of the marker
121+
* (default estimateParameters.pattern = PatternPositionType::ARUCO_CCW_CENTER, estimateParameters.useExtrinsicGuess = false,
122+
* estimateParameters.solvePnPMethod = SOLVEPNP_ITERATIVE).
123+
*
124+
* This function receives the detected markers and returns their pose estimation respect to
125+
* the camera individually. So for each marker, one rotation and translation vector is returned.
126+
* The returned transformation is the one that transforms points from each marker coordinate system
127+
* to the camera coordinate system.
128+
* The marker coordinate system is centered on the middle (by default) or on the top-left corner of the marker,
129+
* with the Z axis perpendicular to the marker plane.
130+
* estimateParameters defines the coordinates of the four corners of the marker in its own coordinate system (by default) are:
131+
* (-markerLength/2, markerLength/2, 0), (markerLength/2, markerLength/2, 0),
132+
* (markerLength/2, -markerLength/2, 0), (-markerLength/2, -markerLength/2, 0)
133+
* @sa use cv::drawFrameAxes to get world coordinate system axis for object points
134+
* @sa @ref tutorial_aruco_detection
135+
* @sa EstimateParameters
136+
* @sa PatternPositionType
137+
*/
138+
CV_EXPORTS_W void estimatePoseSingleMarkers(InputArrayOfArrays corners, float markerLength,
139+
InputArray cameraMatrix, InputArray distCoeffs,
140+
OutputArray rvecs, OutputArray tvecs, OutputArray objPoints = noArray(),
141+
const Ptr<EstimateParameters>& estimateParameters = EstimateParameters::create());
142+
143+
144+
/**
145+
@deprecated Use CharucoBoard::testCharucoCornersCollinear
146+
*/
147+
CV_EXPORTS_W bool testCharucoCornersCollinear(const Ptr<CharucoBoard> &board, InputArray charucoIds);
148+
149+
32150
}
33151
}
34152

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
// This file is part of OpenCV project.
2+
// It is subject to the license terms in the LICENSE file found in the top-level directory
3+
// of this distribution and at http://opencv.org/license.html
4+
#ifndef OPENCV_ARUCO_CALIB_POSE_HPP
5+
#define OPENCV_ARUCO_CALIB_POSE_HPP
6+
#include <opencv2/objdetect/aruco_board.hpp>
7+
8+
namespace cv {
9+
namespace aruco {
10+
11+
//! @addtogroup aruco
12+
//! @{
13+
14+
/**
15+
* @brief Calibrate a camera using aruco markers
16+
*
17+
* @param corners vector of detected marker corners in all frames.
18+
* The corners should have the same format returned by detectMarkers (see #detectMarkers).
19+
* @param ids list of identifiers for each marker in corners
20+
* @param counter number of markers in each frame so that corners and ids can be split
21+
* @param board Marker Board layout
22+
* @param imageSize Size of the image used only to initialize the intrinsic camera matrix.
23+
* @param cameraMatrix Output 3x3 floating-point camera matrix
24+
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . If CV\_CALIB\_USE\_INTRINSIC\_GUESS
25+
* and/or CV_CALIB_FIX_ASPECT_RATIO are specified, some or all of fx, fy, cx, cy must be
26+
* initialized before calling the function.
27+
* @param distCoeffs Output vector of distortion coefficients
28+
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
29+
* @param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each board view
30+
* (e.g. std::vector<cv::Mat>>). That is, each k-th rotation vector together with the corresponding
31+
* k-th translation vector (see the next output parameter description) brings the board pattern
32+
* from the model coordinate space (in which object points are specified) to the world coordinate
33+
* space, that is, a real position of the board pattern in the k-th pattern view (k=0.. *M* -1).
34+
* @param tvecs Output vector of translation vectors estimated for each pattern view.
35+
* @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
36+
* Order of deviations values:
37+
* \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,
38+
* s_4, \tau_x, \tau_y)\f$ If one of parameters is not estimated, it's deviation is equals to zero.
39+
* @param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
40+
* Order of deviations values: \f$(R_1, T_1, \dotsc , R_M, T_M)\f$ where M is number of pattern views,
41+
* \f$R_i, T_i\f$ are concatenated 1x3 vectors.
42+
* @param perViewErrors Output vector of average re-projection errors estimated for each pattern view.
43+
* @param flags flags Different flags for the calibration process (see #calibrateCamera for details).
44+
* @param criteria Termination criteria for the iterative optimization algorithm.
45+
*
46+
* This function calibrates a camera using an Aruco Board. The function receives a list of
47+
* detected markers from several views of the Board. The process is similar to the chessboard
48+
* calibration in calibrateCamera(). The function returns the final re-projection error.
49+
*/
50+
CV_EXPORTS_AS(calibrateCameraArucoExtended)
51+
double calibrateCameraAruco(InputArrayOfArrays corners, InputArray ids, InputArray counter, const Ptr<Board> &board,
52+
Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
53+
OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, OutputArray stdDeviationsIntrinsics,
54+
OutputArray stdDeviationsExtrinsics, OutputArray perViewErrors, int flags = 0,
55+
const TermCriteria& criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON));
56+
57+
/** @overload
58+
* @brief It's the same function as #calibrateCameraAruco but without calibration error estimation.
59+
*/
60+
CV_EXPORTS_W double calibrateCameraAruco(InputArrayOfArrays corners, InputArray ids, InputArray counter,
61+
const Ptr<Board> &board, Size imageSize, InputOutputArray cameraMatrix,
62+
InputOutputArray distCoeffs, OutputArrayOfArrays rvecs = noArray(),
63+
OutputArrayOfArrays tvecs = noArray(), int flags = 0,
64+
const TermCriteria& criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS,
65+
30, DBL_EPSILON));
66+
67+
68+
/**
69+
* @brief Calibrate a camera using Charuco corners
70+
*
71+
* @param charucoCorners vector of detected charuco corners per frame
72+
* @param charucoIds list of identifiers for each corner in charucoCorners per frame
73+
* @param board Marker Board layout
74+
* @param imageSize input image size
75+
* @param cameraMatrix Output 3x3 floating-point camera matrix
76+
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . If CV\_CALIB\_USE\_INTRINSIC\_GUESS
77+
* and/or CV_CALIB_FIX_ASPECT_RATIO are specified, some or all of fx, fy, cx, cy must be
78+
* initialized before calling the function.
79+
* @param distCoeffs Output vector of distortion coefficients
80+
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
81+
* @param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each board view
82+
* (e.g. std::vector<cv::Mat>>). That is, each k-th rotation vector together with the corresponding
83+
* k-th translation vector (see the next output parameter description) brings the board pattern
84+
* from the model coordinate space (in which object points are specified) to the world coordinate
85+
* space, that is, a real position of the board pattern in the k-th pattern view (k=0.. *M* -1).
86+
* @param tvecs Output vector of translation vectors estimated for each pattern view.
87+
* @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
88+
* Order of deviations values:
89+
* \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,
90+
* s_4, \tau_x, \tau_y)\f$ If one of parameters is not estimated, it's deviation is equals to zero.
91+
* @param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
92+
* Order of deviations values: \f$(R_1, T_1, \dotsc , R_M, T_M)\f$ where M is number of pattern views,
93+
* \f$R_i, T_i\f$ are concatenated 1x3 vectors.
94+
* @param perViewErrors Output vector of average re-projection errors estimated for each pattern view.
95+
* @param flags flags Different flags for the calibration process (see #calibrateCamera for details).
96+
* @param criteria Termination criteria for the iterative optimization algorithm.
97+
*
98+
* This function calibrates a camera using a set of corners of a Charuco Board. The function
99+
* receives a list of detected corners and its identifiers from several views of the Board.
100+
* The function returns the final re-projection error.
101+
*/
102+
CV_EXPORTS_AS(calibrateCameraCharucoExtended)
103+
double calibrateCameraCharuco(InputArrayOfArrays charucoCorners, InputArrayOfArrays charucoIds,
104+
const Ptr<CharucoBoard> &board, Size imageSize, InputOutputArray cameraMatrix,
105+
InputOutputArray distCoeffs, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
106+
OutputArray stdDeviationsIntrinsics, OutputArray stdDeviationsExtrinsics,
107+
OutputArray perViewErrors, int flags = 0, const TermCriteria& criteria = TermCriteria(
108+
TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON));
109+
110+
/**
111+
* @brief It's the same function as #calibrateCameraCharuco but without calibration error estimation.
112+
*/
113+
CV_EXPORTS_W double calibrateCameraCharuco(InputArrayOfArrays charucoCorners, InputArrayOfArrays charucoIds,
114+
const Ptr<CharucoBoard> &board, Size imageSize,
115+
InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
116+
OutputArrayOfArrays rvecs = noArray(),
117+
OutputArrayOfArrays tvecs = noArray(), int flags = 0,
118+
const TermCriteria& criteria=TermCriteria(TermCriteria::COUNT +
119+
TermCriteria::EPS, 30, DBL_EPSILON));
120+
//! @}
121+
122+
}
123+
}
124+
#endif

0 commit comments

Comments
 (0)