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_CALIB_POSE_HPP__
5- #define __OPENCV_ARUCO_CALIB_POSE_HPP__
6- #include < opencv2/aruco/board.hpp>
7- #include < opencv2/calib3d.hpp>
4+ #ifndef OPENCV_ARUCO_CALIB_POSE_HPP
5+ #define OPENCV_ARUCO_CALIB_POSE_HPP
6+ #include < opencv2/objdetect/aruco_board.hpp>
87
98namespace cv {
109namespace aruco {
@@ -13,143 +12,54 @@ namespace aruco {
1312// ! @{
1413
1514/* * @brief rvec/tvec define the right handed coordinate system of the marker.
16- * PatternPos defines center this system and axes direction.
15+ *
16+ * PatternPositionType defines center this system and axes direction.
1717 * Axis X (red color) - first coordinate, axis Y (green color) - second coordinate,
1818 * axis Z (blue color) - third coordinate.
19- * @sa estimatePoseSingleMarkers(), @ref tutorial_aruco_detection
19+ * @sa estimatePoseSingleMarkers(), check tutorial_aruco_detection in aruco contrib
2020 */
21- enum PatternPos {
21+ enum PatternPositionType {
2222 /* * @brief The marker coordinate system is centered on the middle of the marker.
23+ *
2324 * The coordinates of the four corners (CCW order) of the marker in its own coordinate system are:
2425 * (-markerLength/2, markerLength/2, 0), (markerLength/2, markerLength/2, 0),
2526 * (markerLength/2, -markerLength/2, 0), (-markerLength/2, -markerLength/2, 0).
2627 *
2728 * These pattern points define this coordinate system:
28- * 
29+ * 
2930 */
3031 ARUCO_CCW_CENTER,
3132 /* * @brief The marker coordinate system is centered on the top-left corner of the marker.
33+ *
3234 * The coordinates of the four corners (CW order) of the marker in its own coordinate system are:
3335 * (0, 0, 0), (markerLength, 0, 0),
3436 * (markerLength, markerLength, 0), (0, markerLength, 0).
3537 *
3638 * These pattern points define this coordinate system:
37- * 
39+ * 
3840 *
3941 * These pattern dots are convenient to use with a chessboard/ChArUco board.
4042 */
4143 ARUCO_CW_TOP_LEFT_CORNER
4244};
4345
4446/* * @brief Pose estimation parameters
45- * @param pattern Defines center this system and axes direction (default PatternPos::ARUCO_CCW_CENTER).
47+ *
48+ * @param pattern Defines center this system and axes direction (default PatternPositionType::ARUCO_CCW_CENTER).
4649 * @param useExtrinsicGuess Parameter used for SOLVEPNP_ITERATIVE. If true (1), the function uses the provided
4750 * rvec and tvec values as initial approximations of the rotation and translation vectors, respectively, and further
4851 * optimizes them (default false).
4952 * @param solvePnPMethod Method for solving a PnP problem: see @ref calib3d_solvePnP_flags (default SOLVEPNP_ITERATIVE).
50- * @sa PatternPos , solvePnP(), @ref tutorial_aruco_detection
53+ * @sa PatternPositionType , solvePnP(), check tutorial_aruco_detection in aruco contrib
5154 */
52- struct CV_EXPORTS_W EstimateParameters {
53- CV_PROP_RW PatternPos pattern;
55+ struct CV_EXPORTS_W_SIMPLE EstimateParameters {
56+ CV_PROP_RW PatternPositionType pattern;
5457 CV_PROP_RW bool useExtrinsicGuess;
55- CV_PROP_RW SolvePnPMethod solvePnPMethod;
58+ CV_PROP_RW int solvePnPMethod;
5659
57- EstimateParameters (): pattern(ARUCO_CCW_CENTER), useExtrinsicGuess(false ),
58- solvePnPMethod (SOLVEPNP_ITERATIVE) {}
59-
60- CV_WRAP static Ptr<EstimateParameters> create () {
61- return makePtr<EstimateParameters>();
62- }
60+ CV_WRAP EstimateParameters ();
6361};
6462
65-
66- /* *
67- * @brief Pose estimation for single markers
68- *
69- * @param corners vector of already detected markers corners. For each marker, its four corners
70- * are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
71- * the dimensions of this array should be Nx4. The order of the corners should be clockwise.
72- * @sa detectMarkers
73- * @param markerLength the length of the markers' side. The returning translation vectors will
74- * be in the same unit. Normally, unit is meters.
75- * @param cameraMatrix input 3x3 floating-point camera matrix
76- * \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
77- * @param distCoeffs vector of distortion coefficients
78- * \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
79- * @param rvecs array of output rotation vectors (@sa Rodrigues) (e.g. std::vector<cv::Vec3d>).
80- * Each element in rvecs corresponds to the specific marker in imgPoints.
81- * @param tvecs array of output translation vectors (e.g. std::vector<cv::Vec3d>).
82- * Each element in tvecs corresponds to the specific marker in imgPoints.
83- * @param objPoints array of object points of all the marker corners
84- * @param estimateParameters set the origin of coordinate system and the coordinates of the four corners of the marker
85- * (default estimateParameters.pattern = PatternPos::ARUCO_CCW_CENTER, estimateParameters.useExtrinsicGuess = false,
86- * estimateParameters.solvePnPMethod = SOLVEPNP_ITERATIVE).
87- *
88- * This function receives the detected markers and returns their pose estimation respect to
89- * the camera individually. So for each marker, one rotation and translation vector is returned.
90- * The returned transformation is the one that transforms points from each marker coordinate system
91- * to the camera coordinate system.
92- * The marker coordinate system is centered on the middle (by default) or on the top-left corner of the marker,
93- * with the Z axis perpendicular to the marker plane.
94- * estimateParameters defines the coordinates of the four corners of the marker in its own coordinate system (by default) are:
95- * (-markerLength/2, markerLength/2, 0), (markerLength/2, markerLength/2, 0),
96- * (markerLength/2, -markerLength/2, 0), (-markerLength/2, -markerLength/2, 0)
97- * @sa use cv::drawFrameAxes to get world coordinate system axis for object points
98- * @sa @ref tutorial_aruco_detection
99- * @sa EstimateParameters
100- * @sa PatternPos
101- */
102- CV_EXPORTS_W void estimatePoseSingleMarkers (InputArrayOfArrays corners, float markerLength,
103- InputArray cameraMatrix, InputArray distCoeffs,
104- OutputArray rvecs, OutputArray tvecs, OutputArray objPoints = noArray(),
105- const Ptr<EstimateParameters>& estimateParameters = EstimateParameters::create());
106-
107- /* *
108- * @brief Pose estimation for a board of markers
109- *
110- * @param corners vector of already detected markers corners. For each marker, its four corners
111- * are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers, the
112- * dimensions of this array should be Nx4. The order of the corners should be clockwise.
113- * @param ids list of identifiers for each marker in corners
114- * @param board layout of markers in the board. The layout is composed by the marker identifiers
115- * and the positions of each marker corner in the board reference system.
116- * @param cameraMatrix input 3x3 floating-point camera matrix
117- * \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
118- * @param distCoeffs vector of distortion coefficients
119- * \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
120- * @param rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
121- * (see cv::Rodrigues). Used as initial guess if not empty.
122- * @param tvec Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.
123- * @param useExtrinsicGuess defines whether initial guess for \b rvec and \b tvec will be used or not.
124- * Used as initial guess if not empty.
125- *
126- * This function receives the detected markers and returns the pose of a marker board composed
127- * by those markers.
128- * A Board of marker has a single world coordinate system which is defined by the board layout.
129- * The returned transformation is the one that transforms points from the board coordinate system
130- * to the camera coordinate system.
131- * Input markers that are not included in the board layout are ignored.
132- * The function returns the number of markers from the input employed for the board pose estimation.
133- * Note that returning a 0 means the pose has not been estimated.
134- * @sa use cv::drawFrameAxes to get world coordinate system axis for object points
135- */
136- CV_EXPORTS_W int estimatePoseBoard (InputArrayOfArrays corners, InputArray ids, const Ptr<Board> &board,
137- InputArray cameraMatrix, InputArray distCoeffs, InputOutputArray rvec,
138- InputOutputArray tvec, bool useExtrinsicGuess = false );
139-
140- /* *
141- * @brief Given a board configuration and a set of detected markers, returns the corresponding
142- * image points and object points to call solvePnP
143- *
144- * @param board Marker board layout.
145- * @param detectedCorners List of detected marker corners of the board.
146- * @param detectedIds List of identifiers for each marker.
147- * @param objPoints Vector of vectors of board marker points in the board coordinate space.
148- * @param imgPoints Vector of vectors of the projections of board marker corner points.
149- */
150- CV_EXPORTS_W void getBoardObjectAndImagePoints (const Ptr<Board> &board, InputArrayOfArrays detectedCorners,
151- InputArray detectedIds, OutputArray objPoints, OutputArray imgPoints);
152-
15363/* *
15464 * @brief Calibrate a camera using aruco markers
15565 *
@@ -203,29 +113,6 @@ CV_EXPORTS_W double calibrateCameraAruco(InputArrayOfArrays corners, InputArray
203113 const TermCriteria& criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS,
204114 30 , DBL_EPSILON));
205115
206- /* *
207- * @brief Pose estimation for a ChArUco board given some of their corners
208- * @param charucoCorners vector of detected charuco corners
209- * @param charucoIds list of identifiers for each corner in charucoCorners
210- * @param board layout of ChArUco board.
211- * @param cameraMatrix input 3x3 floating-point camera matrix
212- * \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
213- * @param distCoeffs vector of distortion coefficients
214- * \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
215- * @param rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
216- * (see cv::Rodrigues).
217- * @param tvec Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.
218- * @param useExtrinsicGuess defines whether initial guess for \b rvec and \b tvec will be used or not.
219- *
220- * This function estimates a Charuco board pose from some detected corners.
221- * The function checks if the input corners are enough and valid to perform pose estimation.
222- * If pose estimation is valid, returns true, else returns false.
223- * @sa use cv::drawFrameAxes to get world coordinate system axis for object points
224- */
225- CV_EXPORTS_W bool estimatePoseCharucoBoard (InputArray charucoCorners, InputArray charucoIds,
226- const Ptr<CharucoBoard> &board, InputArray cameraMatrix,
227- InputArray distCoeffs, InputOutputArray rvec,
228- InputOutputArray tvec, bool useExtrinsicGuess = false );
229116
230117/* *
231118 * @brief Calibrate a camera using Charuco corners
0 commit comments