Skip to content

Commit d980cc3

Browse files
committed
Merge branch 4.x
2 parents 0335ba7 + e247b68 commit d980cc3

File tree

178 files changed

+8973
-47560
lines changed

Some content is hidden

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

178 files changed

+8973
-47560
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_3d opencv_calib WRAP python java objc js)
2+
ocv_define_module(aruco opencv_core opencv_imgproc opencv_3d opencv_calib 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: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,100 @@
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

13-
1413
/**
15-
@deprecated Use class ArucoDetector
14+
* @defgroup aruco Aruco markers, module functionality was moved to objdetect module
15+
* @{
16+
* ArUco Marker Detection, module functionality was moved to objdetect module
17+
* @sa ArucoDetector, CharucoDetector, Board, GridBoard, CharucoBoard
18+
* @}
19+
*/
20+
21+
//! @addtogroup aruco
22+
//! @{
23+
24+
/** @brief detect markers
25+
@deprecated Use class ArucoDetector::detectMarkers
1626
*/
1727
CV_EXPORTS_W void detectMarkers(InputArray image, const Ptr<Dictionary> &dictionary, OutputArrayOfArrays corners,
18-
OutputArray ids, const Ptr<DetectorParameters> &parameters = DetectorParameters::create(),
28+
OutputArray ids, const Ptr<DetectorParameters> &parameters = makePtr<DetectorParameters>(),
1929
OutputArrayOfArrays rejectedImgPoints = noArray());
2030

21-
/**
22-
@deprecated Use class ArucoDetector
31+
/** @brief refine detected markers
32+
@deprecated Use class ArucoDetector::refineDetectedMarkers
2333
*/
2434
CV_EXPORTS_W void refineDetectedMarkers(InputArray image,const Ptr<Board> &board,
2535
InputOutputArrayOfArrays detectedCorners,
2636
InputOutputArray detectedIds, InputOutputArrayOfArrays rejectedCorners,
2737
InputArray cameraMatrix = noArray(), InputArray distCoeffs = noArray(),
2838
float minRepDistance = 10.f, float errorCorrectionRate = 3.f,
2939
bool checkAllOrders = true, OutputArray recoveredIdxs = noArray(),
30-
const Ptr<DetectorParameters> &parameters = DetectorParameters::create());
40+
const Ptr<DetectorParameters> &parameters = makePtr<DetectorParameters>());
41+
42+
/** @brief draw planar board
43+
@deprecated Use Board::generateImage
44+
*/
45+
CV_EXPORTS_W void drawPlanarBoard(const Ptr<Board> &board, Size outSize, OutputArray img, int marginSize,
46+
int borderBits);
47+
48+
/** @brief get board object and image points
49+
@deprecated Use Board::matchImagePoints
50+
*/
51+
CV_EXPORTS_W void getBoardObjectAndImagePoints(const Ptr<Board> &board, InputArrayOfArrays detectedCorners,
52+
InputArray detectedIds, OutputArray objPoints, OutputArray imgPoints);
53+
54+
55+
/** @deprecated Use cv::solvePnP
56+
*/
57+
CV_EXPORTS_W int estimatePoseBoard(InputArrayOfArrays corners, InputArray ids, const Ptr<Board> &board,
58+
InputArray cameraMatrix, InputArray distCoeffs, InputOutputArray rvec,
59+
InputOutputArray tvec, bool useExtrinsicGuess = false);
60+
61+
/**
62+
* @brief Pose estimation for a ChArUco board given some of their corners
63+
* @param charucoCorners vector of detected charuco corners
64+
* @param charucoIds list of identifiers for each corner in charucoCorners
65+
* @param board layout of ChArUco board.
66+
* @param cameraMatrix input 3x3 floating-point camera matrix
67+
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
68+
* @param distCoeffs vector of distortion coefficients
69+
* \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
70+
* @param rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
71+
* (see cv::Rodrigues).
72+
* @param tvec Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.
73+
* @param useExtrinsicGuess defines whether initial guess for \b rvec and \b tvec will be used or not.
74+
*
75+
* This function estimates a Charuco board pose from some detected corners.
76+
* The function checks if the input corners are enough and valid to perform pose estimation.
77+
* If pose estimation is valid, returns true, else returns false.
78+
* @sa use cv::drawFrameAxes to get world coordinate system axis for object points
79+
*/
80+
CV_EXPORTS_W bool estimatePoseCharucoBoard(InputArray charucoCorners, InputArray charucoIds,
81+
const Ptr<CharucoBoard> &board, InputArray cameraMatrix,
82+
InputArray distCoeffs, InputOutputArray rvec,
83+
InputOutputArray tvec, bool useExtrinsicGuess = false);
84+
85+
/** @deprecated Use cv::solvePnP
86+
*/
87+
CV_EXPORTS_W void estimatePoseSingleMarkers(InputArrayOfArrays corners, float markerLength,
88+
InputArray cameraMatrix, InputArray distCoeffs,
89+
OutputArray rvecs, OutputArray tvecs, OutputArray objPoints = noArray(),
90+
const Ptr<EstimateParameters>& estimateParameters = makePtr<EstimateParameters>());
91+
92+
93+
/** @deprecated Use CharucoBoard::checkCharucoCornersCollinear
94+
*/
95+
CV_EXPORTS_W bool testCharucoCornersCollinear(const Ptr<CharucoBoard> &board, InputArray charucoIds);
96+
97+
//! @}
3198

3299
}
33100
}

modules/aruco/include/opencv2/aruco/aruco_calib_pose.hpp renamed to modules/aruco/include/opencv2/aruco/aruco_calib.hpp

Lines changed: 18 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
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

98
namespace cv {
109
namespace 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-
* ![Image with axes drawn](images/singlemarkersaxes.jpg)
29+
* ![Image with axes drawn](tutorials/images/singlemarkersaxes.jpg)
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-
* ![Image with axes drawn](images/singlemarkersaxes2.jpg)
39+
* ![Image with axes drawn](tutorials/images/singlemarkersaxes2.jpg)
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

Comments
 (0)