Skip to content

Commit 774faf3

Browse files
author
AleksandrPanov
committed
update docs and refactoring
1 parent 3a41fd6 commit 774faf3

File tree

3 files changed

+87
-53
lines changed

3 files changed

+87
-53
lines changed

modules/aruco/include/opencv2/aruco/board.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ class CV_EXPORTS_W Board {
5656
///
5757
/// Markers are placed in a certain order - row by row, left to right in every row.
5858
/// For M markers, the size is Mx4.
59-
CV_PROP std::vector< std::vector< Point3f > > objPoints;
59+
CV_PROP std::vector<std::vector<Point3f> > objPoints;
6060

6161
/// the dictionary of markers employed for this board
6262
CV_PROP Ptr<Dictionary> dictionary;
6363

6464
/// vector of the identifiers of the markers in the board (same size than objPoints)
6565
/// The identifiers refers to the board dictionary
66-
CV_PROP_RW std::vector< int > ids;
66+
CV_PROP_RW std::vector<int> ids;
6767

6868
/// coordinate of the bottom right corner of the board, is set when calling the function create()
6969
CV_PROP Point3f rightBottomBorder;
@@ -153,11 +153,11 @@ class CV_EXPORTS_W GridBoard : public Board {
153153
class CV_EXPORTS_W CharucoBoard : public Board {
154154
public:
155155
// vector of chessboard 3D corners precalculated
156-
CV_PROP std::vector< Point3f > chessboardCorners;
156+
CV_PROP std::vector<Point3f> chessboardCorners;
157157

158158
// for each charuco corner, nearest marker id and nearest marker corner id of each marker
159-
CV_PROP std::vector< std::vector< int > > nearestMarkerIdx;
160-
CV_PROP std::vector< std::vector< int > > nearestMarkerCorners;
159+
CV_PROP std::vector<std::vector<int> > nearestMarkerIdx;
160+
CV_PROP std::vector<std::vector<int> > nearestMarkerCorners;
161161

162162
/**
163163
* @brief Draw a ChArUco board

modules/aruco/include/opencv2/aruco_detector.hpp

Lines changed: 80 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
/**
1010
* @defgroup aruco ArUco Marker Detection
1111
* This module is dedicated to square fiducial markers (also known as Augmented Reality Markers)
12-
* These markers are useful for easy, fast and robust camera pose estimation.ç
12+
* These markers are useful for easy, fast and robust camera pose estimation.
1313
*
14-
* The main functionalities are:
14+
* The main functionality of ArucoDetector class is:
1515
* - Detection of markers in an image
16+
*
17+
* There are even more functionalities implemented in charuco.hpp and aruco_calib_pose.hpp:
1618
* - Pose estimation from a single marker or from a board/set of markers
1719
* - Detection of ChArUco board for high subpixel accuracy
1820
* - Camera calibration from both, ArUco boards and ChArUco boards.
@@ -48,6 +50,9 @@ enum CornerRefineMethod{
4850
CORNER_REFINE_APRILTAG, ///< Tag and corners detection based on the AprilTag 2 approach @cite wang2016iros
4951
};
5052

53+
/**
54+
* @brief struct DetectorParameters is used by ArucoDetector
55+
*/
5156
struct CV_EXPORTS_W DetectorParameters {
5257
DetectorParameters() {
5358
adaptiveThreshWinSizeMin = 3;
@@ -84,8 +89,7 @@ struct CV_EXPORTS_W DetectorParameters {
8489
minMarkerLengthRatioOriginalImg = 0.0;
8590
};
8691

87-
/**
88-
* @brief Create a new set of DetectorParameters with default values.
92+
/** @brief Create a new set of DetectorParameters with default values.
8993
*/
9094
CV_WRAP static Ptr<DetectorParameters> create() {
9195
Ptr<DetectorParameters> params = makePtr<DetectorParameters>();
@@ -114,12 +118,14 @@ struct CV_EXPORTS_W DetectorParameters {
114118
/// constant for adaptive thresholding before finding contours (default 7)
115119
CV_PROP_RW double adaptiveThreshConstant;
116120

117-
/// determine minimum perimeter for marker contour to be detected. This is defined as a rate respect to the
118-
/// maximum dimension of the input image (default 0.03).
121+
/** @brief determine minimum perimeter for marker contour to be detected. This is defined as a rate respect to the
122+
* maximum dimension of the input image (default 0.03).
123+
*/
119124
CV_PROP_RW double minMarkerPerimeterRate;
120125

121-
/// determine maximum perimeter for marker contour to be detected. This is defined as a rate respect to
122-
/// the maximum dimension of the input image (default 4.0).
126+
/** @brief determine maximum perimeter for marker contour to be detected. This is defined as a rate respect to
127+
* the maximum dimension of the input image (default 4.0).
128+
*/
123129
CV_PROP_RW double maxMarkerPerimeterRate;
124130

125131
/// minimum accuracy during the polygonal approximation process to determine which contours are squares. (default 0.03)
@@ -131,15 +137,17 @@ struct CV_EXPORTS_W DetectorParameters {
131137
/// minimum distance of any corner to the image border for detected markers (in pixels) (default 3)
132138
CV_PROP_RW int minDistanceToBorder;
133139

134-
/// minimum mean distance beetween two marker corners to be considered imilar, so that the
135-
/// smaller one is removed. The rate is relative to the smaller perimeter of the two markers (default 0.05).
140+
/** @brief minimum mean distance beetween two marker corners to be considered imilar, so that the
141+
* smaller one is removed. The rate is relative to the smaller perimeter of the two markers (default 0.05).
142+
*/
136143
CV_PROP_RW double minMarkerDistanceRate;
137144

138-
/// corner refinement method (default CORNER_REFINE_NONE).
139-
/// 0:CORNER_REFINE_NONE, no refinement.
140-
/// 1: CORNER_REFINE_SUBPIX, do subpixel refinement.
141-
/// 2: CORNER_REFINE_CONTOUR use contour-Points,
142-
/// 3: CORNER_REFINE_APRILTAG use the AprilTag2 approach).
145+
/** @brief default CORNER_REFINE_NONE.
146+
* 0:CORNER_REFINE_NONE, no refinement.
147+
* 1: CORNER_REFINE_SUBPIX, do subpixel refinement.
148+
* 2: CORNER_REFINE_CONTOUR use contour-Points,
149+
* 3: CORNER_REFINE_APRILTAG use the AprilTag2 approach).
150+
*/
143151
CV_PROP_RW int cornerRefinementMethod;
144152

145153
/// window size for the corner refinement process (in pixels) (default 5).
@@ -157,25 +165,29 @@ struct CV_EXPORTS_W DetectorParameters {
157165
/// number of bits (per dimension) for each cell of the marker when removing the perspective (default 4).
158166
CV_PROP_RW int perspectiveRemovePixelPerCell;
159167

160-
/// width of the margin of pixels on each cell not considered for the
161-
/// determination of the cell bit. Represents the rate respect to the total size of the cell, i.e.
162-
/// perspectiveRemovePixelPerCell (default 0.13)
168+
/** @brief width of the margin of pixels on each cell not considered for the
169+
* determination of the cell bit. Represents the rate respect to the total size of the cell, i.e.
170+
* perspectiveRemovePixelPerCell (default 0.13)
171+
*/
163172
CV_PROP_RW double perspectiveRemoveIgnoredMarginPerCell;
164173

165-
/// maximum number of accepted erroneous bits in the border (i.e. number of allowed
166-
/// white bits in the border). Represented as a rate respect to the total number of bits per marker (default 0.35).
174+
/** @brief maximum number of accepted erroneous bits in the border (i.e. number of allowed
175+
* white bits in the border). Represented as a rate respect to the total number of bits per marker (default 0.35).
176+
*/
167177
CV_PROP_RW double maxErroneousBitsInBorderRate;
168178

169-
/// minimun standard deviation in pixels values during the decodification step to apply Otsu
170-
/// thresholding (otherwise, all the bits are set to 0 or 1 depending on mean higher than 128 or not) (default 5.0)
179+
/** @brief minimun standard deviation in pixels values during the decodification step to apply Otsu
180+
* thresholding (otherwise, all the bits are set to 0 or 1 depending on mean higher than 128 or not) (default 5.0)
181+
*/
171182
CV_PROP_RW double minOtsuStdDev;
172183

173184
/// error correction rate respect to the maximun error correction capability for each dictionary (default 0.6).
174185
CV_PROP_RW double errorCorrectionRate;
175186

176-
// April :: User-configurable parameters.
177-
/// detection of quads can be done on a lower-resolution image, improving speed at a cost of
178-
/// pose accuracy and a slight decrease in detection rate. Decoding the binary payload is still
187+
/** @brief April :: User-configurable parameters.
188+
* detection of quads can be done on a lower-resolution image, improving speed at a cost of
189+
* pose accuracy and a slight decrease in detection rate. Decoding the binary payload is still
190+
*/
179191
CV_PROP_RW float aprilTagQuadDecimate;
180192

181193
/// what Gaussian blur should be applied to the segmented image (used for quad detection?)
@@ -188,28 +200,32 @@ struct CV_EXPORTS_W DetectorParameters {
188200
/// how many corner candidates to consider when segmenting a group of pixels into a quad (default 10).
189201
CV_PROP_RW int aprilTagMaxNmaxima;
190202

191-
/// reject quads where pairs of edges have angles that are close to straight or close to 180 degrees.
192-
/// Zero means that no quads are rejected. (In radians) (default 10*PI/180)
203+
/** @brief reject quads where pairs of edges have angles that are close to straight or close to 180 degrees.
204+
* Zero means that no quads are rejected. (In radians) (default 10*PI/180)
205+
*/
193206
CV_PROP_RW float aprilTagCriticalRad;
194207

195208
/// when fitting lines to the contours, what is the maximum mean squared error
196209
CV_PROP_RW float aprilTagMaxLineFitMse;
197210

198-
/// when we build our model of black & white pixels, we add an extra check that the
199-
/// white model must be (overall) brighter than the black model. How much brighter? (in pixel values, [0,255]).
200-
/// (default 5)
211+
/** @brief when we build our model of black & white pixels, we add an extra check that the
212+
* white model must be (overall) brighter than the black model. How much brighter? (in pixel values, [0,255]).
213+
* (default 5)
214+
*/
201215
CV_PROP_RW int aprilTagMinWhiteBlackDiff;
202216

203217
/// should the thresholded image be deglitched? Only useful for very noisy images (default 0).
204218
CV_PROP_RW int aprilTagDeglitch;
205219

206-
/// to check if there is a white marker. In order to generate a "white" marker just invert a
207-
/// normal marker by using a tilde, ~markerImage. (default false)
220+
/** @brief to check if there is a white marker. In order to generate a "white" marker just invert a
221+
* normal marker by using a tilde, ~markerImage. (default false)
222+
*/
208223
CV_PROP_RW bool detectInvertedMarker;
209224

210-
/// new Aruco functionality proposed in the paper:
211-
/// Romero-Ramirez et al: Speeded up detection of squared fiducial markers (2018)
212-
/// https://www.researchgate.net/publication/325787310_Speeded_Up_Detection_of_Squared_Fiducial_Markers
225+
/** @brief new Aruco functionality proposed in the paper:
226+
* Romero-Ramirez et al: Speeded up detection of squared fiducial markers (2018)
227+
* https://www.researchgate.net/publication/325787310_Speeded_Up_Detection_of_Squared_Fiducial_Markers
228+
*/
213229

214230
/// to enable the new and faster Aruco detection strategy.
215231
CV_PROP_RW bool useAruco3Detection;
@@ -224,6 +240,9 @@ struct CV_EXPORTS_W DetectorParameters {
224240
bool readWrite(const Ptr<FileNode>& readNode = nullptr, const Ptr<FileStorage>& writeStorage = nullptr);
225241
};
226242

243+
/**
244+
* @brief struct RefineParameters is used by ArucoDetector
245+
*/
227246
struct CV_EXPORTS_W RefineParameters {
228247
RefineParameters() {
229248
minRepDistance = 10.f;
@@ -245,37 +264,53 @@ struct CV_EXPORTS_W RefineParameters {
245264
*/
246265
CV_WRAP bool readRefineParameters(const FileNode& fn);
247266

248-
/**
249-
* @brief Write a set of RefineParameters to FileStorage
267+
/** @brief Write a set of RefineParameters to FileStorage
250268
*/
251269
CV_WRAP bool writeRefineParameters(const Ptr<FileStorage>& fs);
252270

253-
/// minRepDistance minimum distance between the corners of the rejected candidate and the reprojected marker in
254-
/// order to consider it as a correspondence.
271+
/** @brief minRepDistance minimum distance between the corners of the rejected candidate and the reprojected marker in
272+
* order to consider it as a correspondence.
273+
*/
255274
CV_PROP_RW float minRepDistance;
256-
/// minRepDistance rate of allowed erroneous bits respect to the error correction
257-
/// capability of the used dictionary. -1 ignores the error correction step.
275+
/** @brief minRepDistance rate of allowed erroneous bits respect to the error correction
276+
* capability of the used dictionary. -1 ignores the error correction step.
277+
*/
258278
CV_PROP_RW float errorCorrectionRate;
259-
/// checkAllOrders consider the four posible corner orders in the rejectedCorners array.
260-
// * If it set to false, only the provided corner order is considered (default true).
279+
/** @brief checkAllOrders consider the four posible corner orders in the rejectedCorners array.
280+
* If it set to false, only the provided corner order is considered (default true).
281+
*/
261282
CV_PROP_RW bool checkAllOrders;
262283
private:
263284
bool readWrite(const Ptr<FileNode>& readNode = nullptr, const Ptr<FileStorage>& writeStorage = nullptr);
264285
};
265286

287+
/**
288+
* @brief
289+
* The main functionality of ArucoDetector class is detection of markers in an image with detectMarkers() method.
290+
* After detecting some markers in the image, you can try to find undetected markers from this dictionary with
291+
* refineDetectedMarkers() method.
292+
* @see DetectorParameters, RefineParameters
293+
*/
266294
class CV_EXPORTS_W ArucoDetector : public Algorithm
267295
{
268296
public:
269297
/// dictionary indicates the type of markers that will be searched
270298
CV_PROP_RW Ptr<Dictionary> dictionary;
271299

272-
/// marker detection parameters
300+
/// marker detection parameters, check DetectorParameters docs to see available settings
273301
CV_PROP_RW Ptr<DetectorParameters> params;
274302

275303
/// marker refine parameters
276304
CV_PROP_RW Ptr<RefineParameters> refineParams;
277305

278-
ArucoDetector(const Ptr<Dictionary> &_dictionary = getPredefinedDictionary(DICT_4X4_50), const Ptr<DetectorParameters> &_params = DetectorParameters::create(),
306+
/**
307+
* @brief Basic ArucoDetector constructor
308+
* @param _dictionary indicates the type of markers that will be searched
309+
* @param _params marker detection parameters
310+
* @param _refineParams marker refine detection parameters
311+
*/
312+
ArucoDetector(const Ptr<Dictionary> &_dictionary = getPredefinedDictionary(DICT_4X4_50),
313+
const Ptr<DetectorParameters> &_params = DetectorParameters::create(),
279314
const Ptr<RefineParameters> &_refineParams = RefineParameters::create()):
280315
dictionary(_dictionary), params(_params), refineParams(_refineParams) {}
281316

@@ -303,7 +338,6 @@ class CV_EXPORTS_W ArucoDetector : public Algorithm
303338
* @note The function does not correct lens distortion or takes it into account. It's recommended to undistort
304339
* input image with corresponging camera model, if camera parameters are known
305340
* @sa undistort, estimatePoseSingleMarkers, estimatePoseBoard
306-
*
307341
*/
308342
CV_WRAP void detectMarkers(InputArray image, OutputArrayOfArrays corners, OutputArray ids,
309343
OutputArrayOfArrays rejectedImgPoints = noArray());

modules/aruco/test/test_aruco_utils.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static inline void projectMarker(Mat& img, Ptr<aruco::Board> board, int markerIn
6969

7070
// projected corners
7171
Mat distCoeffs(5, 1, CV_64FC1, Scalar::all(0));
72-
vector< Point2f > corners;
72+
vector<Point2f> corners;
7373

7474
// get max coordinate of board
7575
Point3f maxCoord = board->rightBottomBorder;
@@ -82,7 +82,7 @@ static inline void projectMarker(Mat& img, Ptr<aruco::Board> board, int markerIn
8282
projectPoints(objPoints, rvec, tvec, cameraMatrix, distCoeffs, corners);
8383

8484
// get perspective transform
85-
vector< Point2f > originalCorners;
85+
vector<Point2f> originalCorners;
8686
originalCorners.push_back(Point2f(0, 0));
8787
originalCorners.push_back(Point2f((float)markerSizePixels, 0));
8888
originalCorners.push_back(Point2f((float)markerSizePixels, (float)markerSizePixels));

0 commit comments

Comments
 (0)