Skip to content

Commit a1b3c84

Browse files
atinfinityvpisarev
authored andcommitted
updated aruco tutorial (#1263)
1 parent 68736a2 commit a1b3c84

File tree

5 files changed

+94
-96
lines changed

5 files changed

+94
-96
lines changed

modules/aruco/tutorials/aruco_board_detection/aruco_board_detection.markdown

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ corners) are employed.
2626

2727
The aruco module allows the use of Boards. The main class is the ```cv::aruco::Board``` class which defines the Board layout:
2828

29-
``` c++
29+
@code{.cpp}
3030
class Board {
3131
public:
3232
std::vector<std::vector<cv::Point3f> > objPoints;
3333
cv::Ptr<cv::aruco::Dictionary> dictionary;
3434
std::vector<int> ids;
3535
};
36-
```
36+
@endcode
3737

3838
A object of type ```Board``` has three parameters:
3939
- The ```objPoints``` structure is the list of corner positions in the 3d Board reference system, i.e. its layout.
@@ -51,7 +51,7 @@ In fact, to use marker boards, a standard marker detection should be done before
5151

5252
The aruco module provides a specific function, ```estimatePoseBoard()```, to perform pose estimation for boards:
5353

54-
``` c++
54+
@code{.cpp}
5555
cv::Mat inputImage;
5656
// camera parameters are read from somewhere
5757
cv::Mat cameraMatrix, distCoeffs;
@@ -67,7 +67,7 @@ The aruco module provides a specific function, ```estimatePoseBoard()```, to per
6767
cv::Vec3d rvec, tvec;
6868
int valid = cv::aruco::estimatePoseBoard(markerCorners, markerIds, board, cameraMatrix, distCoeffs, rvec, tvec);
6969
}
70-
```
70+
@endcode
7171

7272
The parameters of estimatePoseBoard are:
7373

@@ -120,9 +120,9 @@ A ```GridBoard``` object can be defined using the following parameters:
120120

121121
This object can be easily created from these parameters using the ```cv::aruco::GridBoard::create()``` static function:
122122

123-
``` c++
123+
@code{.cpp}
124124
cv::aruco::GridBoard board = cv::aruco::GridBoard::create(5, 7, 0.04, 0.01, dictionary);
125-
```
125+
@endcode
126126

127127
- The first and second parameters are the number of markers in the X and Y direction respectively.
128128
- The third and fourth parameters are the marker length and the marker separation respectively. They can be provided
@@ -136,11 +136,11 @@ through ```board.ids```, like in the ```Board``` parent class.
136136
After creating a Grid Board, we probably want to print it and use it. A function to generate the image
137137
of a ```GridBoard``` is provided in ```cv::aruco::GridBoard::draw()```. For example:
138138

139-
``` c++
139+
@code{.cpp}
140140
cv::Ptr<cv::aruco::GridBoard> board = cv::aruco::GridBoard::create(5, 7, 0.04, 0.01, dictionary);
141141
cv::Mat boardImage;
142142
board->draw( cv::Size(600, 500), boardImage, 10, 1 );
143-
```
143+
@endcode
144144

145145
- The first parameter is the size of the output image in pixels. In this case 600x500 pixels. If this is not proportional
146146
to the board dimensions, it will be centered on the image.
@@ -156,13 +156,13 @@ The output image will be something like this:
156156
A full working example of board creation is included in the ```create_board.cpp``` inside the module samples folder.
157157

158158
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
159-
``` c++
159+
@code{.cpp}
160160
"_output path_/aboard.png" -w=5 -h=7 -l=100 -s=10 -d=10
161-
```
161+
@endcode
162162

163163
Finally, a full example of board detection:
164164

165-
``` c++
165+
@code{.cpp}
166166
cv::VideoCapture inputVideo;
167167
inputVideo.open(0);
168168

@@ -199,7 +199,7 @@ Finally, a full example of board detection:
199199
if (key == 27)
200200
break;
201201
}
202-
```
202+
@endcode
203203

204204
Sample video:
205205

@@ -210,9 +210,9 @@ Sample video:
210210
A full working example is included in the ```detect_board.cpp``` inside the module samples folder.
211211

212212
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
213-
``` c++
213+
@code{.cpp}
214214
-c="_path_"/calib.txt" "_path_/aboard.png" -w=5 -h=7 -l=100 -s=10 -d=10
215-
```
215+
@endcode
216216

217217

218218

@@ -255,7 +255,7 @@ internal bits are not analyzed at all and only the corner distances are evaluate
255255

256256
This is an example of using the ```refineDetectedMarkers()``` function:
257257

258-
``` c++
258+
@code{.cpp}
259259
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
260260
cv::Ptr<cv::aruco::GridBoard> board = cv::aruco::GridBoard::create(5, 7, 0.04, 0.01, dictionary);
261261
std::vector<int> markerIds;
@@ -265,7 +265,7 @@ This is an example of using the ```refineDetectedMarkers()``` function:
265265
cv::aruco::refineDetectedMarkersinputImage, board, markerCorners, markerIds, rejectedCandidates);
266266
// After calling this function, if any new marker has been detected it will be removed from rejectedCandidates and included
267267
// at the end of markerCorners and markerIds
268-
```
268+
@endcode
269269

270270
It must also be noted that, in some cases, if the number of detected markers in the first place is too low (for instance only
271271
1 or 2 markers), the projections of the missing markers can be of bad quality, producing erroneous correspondences.

modules/aruco/tutorials/aruco_calibration/aruco_calibration.markdown

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ visible in all the viewpoints.
3232

3333
The function to calibrate is ```calibrateCameraCharuco()```. Example:
3434

35-
``` c++
35+
@code{.cpp}
3636
cv::Ptr<aruco::CharucoBoard> board = ... // create charuco board
3737
cv::Size imgSize = ... // camera image size
3838

@@ -48,7 +48,7 @@ The function to calibrate is ```calibrateCameraCharuco()```. Example:
4848
int calibrationFlags = ... // Set calibration flags (same than in calibrateCamera() function)
4949

5050
double repError = cv::aruco::calibrateCameraCharuco(allCharucoCorners, allCharucoIds, board, imgSize, cameraMatrix, distCoeffs, rvecs, tvecs, calibrationFlags);
51-
```
51+
@endcode
5252

5353
The ChArUco corners and ChArUco identifiers captured on each viewpoint are stored in the vectors ```allCharucoCorners``` and ```allCharucoIds```, one element per viewpoint.
5454

@@ -62,9 +62,9 @@ Finally, the ```calibrationFlags``` parameter determines some of the options for
6262
A full working example is included in the ```calibrate_camera_charuco.cpp``` inside the module samples folder.
6363

6464
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
65-
``` c++
65+
@code{.cpp}
6666
_output path_" -dp="_path_/detector_params.yml" -w=5 -h=7 -sl=0.04 -ml=0.02 -d=10
67-
```
67+
@endcode
6868

6969

7070

@@ -80,7 +80,7 @@ requires the detections of an ArUco board from different viewpoints.
8080

8181
Example of ```calibrateCameraAruco()``` use:
8282

83-
``` c++
83+
@code{.cpp}
8484
cv::Ptr<aruco::Board> board = ... // create aruco board
8585
cv::Size imgSize = ... // camera image size
8686

@@ -97,7 +97,7 @@ Example of ```calibrateCameraAruco()``` use:
9797
int calibrationFlags = ... // Set calibration flags (same than in calibrateCamera() function)
9898

9999
double repError = cv::aruco::calibrateCameraAruco(allCornersConcatenated, allIdsConcatenated, markerCounterPerFrame, board, imgSize, cameraMatrix, distCoeffs, rvecs, tvecs, calibrationFlags);
100-
```
100+
@endcode
101101

102102
In this case, and contrary to the ```calibrateCameraCharuco()``` function, the detected markers on each viewpoint are concatenated in the arrays ```allCornersConcatenated``` and
103103
```allCornersConcatenated``` (the first two parameters). The third parameter, the array ```markerCounterPerFrame```, indicates the number of marker detected on each viewpoint.
@@ -107,6 +107,6 @@ any ```Board``` object.
107107
A full working example is included in the ```calibrate_camera.cpp``` inside the module samples folder.
108108

109109
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
110-
``` c++
110+
@code{.cpp}
111111
"_path_/calib.txt" -w=5 -h=7 -l=100 -s=10 -d=10
112-
```
112+
@endcode

modules/aruco/tutorials/aruco_detection/aruco_detection.markdown

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ a popular library for detection of square fiducial markers developed by Rafael M
1919
> Pattern Recogn. 47, 6 (June 2014), 2280-2292. DOI=10.1016/j.patcog.2014.01.005
2020
2121
The aruco functionalities are included in:
22-
``` c++
22+
@code{.cpp}
2323
#include <opencv2/aruco.hpp>
24-
```
24+
@endcode
2525

2626

2727
Markers and Dictionaries
@@ -69,11 +69,11 @@ Marker images can be generated using the ```drawMarker()``` function.
6969

7070
For example, lets analyze the following call:
7171

72-
``` c++
72+
@code{.cpp}
7373
cv::Mat markerImage;
7474
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
7575
cv::aruco::drawMarker(dictionary, 23, 200, markerImage, 1);
76-
```
76+
@endcode
7777

7878
First, the ```Dictionary``` object is created by choosing one of the predefined dictionaries in the aruco module.
7979
Concretely, this dictionary is composed by 250 markers and a marker size of 6x6 bits (```DICT_6X6_250```).
@@ -104,9 +104,9 @@ The generated image is:
104104
A full working example is included in the ```create_marker.cpp``` inside the module samples folder.
105105

106106
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
107-
``` c++
107+
@code{.cpp}
108108
"/Users/Sarthak/Dropbox/OpenCV_GSoC/marker.png" -d=10 -id=1
109-
```
109+
@endcode
110110

111111
Marker Detection
112112
------
@@ -153,15 +153,15 @@ previous detected markers returned by ```detectMarkers()```.
153153

154154
An example of marker detection:
155155

156-
``` c++
156+
@code{.cpp}
157157
cv::Mat inputImage;
158158
...
159159
std::vector<int> markerIds;
160160
std::vector<std::vector<cv::Point2f>> markerCorners, rejectedCandidates;
161161
cv::Ptr<cv::aruco::DetectorParameters> parameters;
162162
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
163163
cv::aruco::detectMarkers(inputImage, dictionary, markerCorners, markerIds, parameters, rejectedCandidates);
164-
```
164+
@endcode
165165

166166
The parameters of ```detectMarkers``` are:
167167

@@ -185,10 +185,10 @@ The next thing you probably want to do after ```detectMarkers()``` is checking t
185185
been correctly detected. Fortunately, the aruco module provides a function to draw the detected
186186
markers in the input image, this function is ```drawDetectedMarkers()```. For example:
187187

188-
``` c++
188+
@code{.cpp}
189189
cv::Mat outputImage
190190
cv::aruco::drawDetectedMarkers(image, markerCorners, markerIds);
191-
```
191+
@endcode
192192

193193
- ```image``` is the input/output image where the markers will be drawn (it will normally be the same image where the markers were detected).
194194
- ```markerCorners``` and ```markerIds``` are the structures of the detected markers in the same format
@@ -201,7 +201,7 @@ Note that this function is only provided for visualization and its use can be pe
201201
With these two functions we can create a basic marker detection loop to detect markers from our
202202
camera:
203203

204-
``` c++
204+
@code{.cpp}
205205
cv::VideoCapture inputVideo;
206206
inputVideo.open(0);
207207
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
@@ -223,17 +223,17 @@ camera:
223223
if (key == 27)
224224
break;
225225
}
226-
```
226+
@endcode
227227

228228
Note that some of the optional parameters have been omitted, like the detection parameter object or the
229229
output vector of rejected candidates.
230230

231231
A full working example is included in the ```detect_markers.cpp``` inside the module samples folder.
232232

233233
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
234-
``` c++
234+
@code{.cpp}
235235
-c="_path_/calib.txt" -d=10
236-
```
236+
@endcode
237237

238238

239239

@@ -262,12 +262,12 @@ information).
262262

263263
The aruco module provides a function to estimate the poses of all the detected markers:
264264

265-
``` c++
265+
@code{.cpp}
266266
cv::Mat cameraMatrix, distCoeffs;
267267
...
268268
std::vector<cv::Vec3d> rvecs, tvecs;
269269
cv::aruco::estimatePoseSingleMarkers(corners, 0.05, cameraMatrix, distCoeffs, rvecs, tvecs);
270-
```
270+
@endcode
271271

272272
- The ```corners``` parameter is the vector of marker corners returned by the ```detectMarkers()``` function.
273273
- The second parameter is the size of the marker side in meters or in any other unit. Note that the
@@ -284,9 +284,9 @@ with the Z axis pointing out, as in the following image. Axis-color corresponden
284284
The aruco module provides a function to draw the axis as in the image above, so pose estimation can be
285285
checked:
286286

287-
``` c++
287+
@code{.cpp}
288288
cv::aruco::drawAxis(image, cameraMatrix, distCoeffs, rvec, tvec, 0.1);
289-
```
289+
@endcode
290290

291291
- ```image``` is the input/output image where the axis will be drawn (it will normally be the same image where the markers were detected).
292292
- ```cameraMatrix``` and ```distCoeffs``` are the camera calibration parameters.
@@ -295,7 +295,7 @@ checked:
295295

296296
A basic full example for pose estimation from single markers:
297297

298-
``` c++
298+
@code{.cpp}
299299
cv::VideoCapture inputVideo;
300300
inputVideo.open(0);
301301

@@ -330,7 +330,7 @@ A basic full example for pose estimation from single markers:
330330
if (key == 27)
331331
break;
332332
}
333-
```
333+
@endcode
334334

335335
Sample video:
336336

@@ -341,9 +341,9 @@ Sample video:
341341
A full working example is included in the ```detect_markers.cpp``` inside the module samples folder.
342342

343343
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
344-
``` c++
344+
@code{.cpp}
345345
-c="_path_/calib.txt" -d=10
346-
```
346+
@endcode
347347

348348

349349

@@ -373,9 +373,9 @@ you can increase your system robustness:
373373
This is the easiest way to select a dictionary. The aruco module includes a set of predefined dictionaries
374374
of a variety of marker sizes and number of markers. For instance:
375375

376-
``` c++
376+
@code{.cpp}
377377
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
378-
```
378+
@endcode
379379

380380
DICT_6X6_250 is an example of predefined dictionary of markers with 6x6 bits and a total of 250
381381
markers.
@@ -389,9 +389,9 @@ The smaller the dictionary, the higher the inter-marker distance.
389389
The dictionary can be generated automatically to adjust to the desired number of markers and bits, so that
390390
the inter-marker distance is optimized:
391391

392-
``` c++
392+
@code{.cpp}
393393
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::generateCustomDictionary(36, 5);
394-
```
394+
@endcode
395395

396396
This will generate a customized dictionary composed by 36 markers of 5x5 bits. The process can take several
397397
seconds, depending on the parameters (it is slower for larger dictionaries and higher number of bits).
@@ -405,7 +405,7 @@ the ```Dictionary``` object parameters need to be assigned manually. It must be
405405
The ```Dictionary``` parameters are:
406406

407407

408-
``` c++
408+
@code{.cpp}
409409
class Dictionary {
410410
public:
411411

@@ -416,10 +416,9 @@ The ```Dictionary``` parameters are:
416416
...
417417

418418
}
419+
@endcode
419420

420-
```
421-
422-
```bytesList``` is the array that contains all the information about the marker codes. ```markerSize``` is the size
421+
<code>bytesList</code> is the array that contains all the information about the marker codes. ```markerSize``` is the size
423422
of each marker dimension (for instance, 5 for markers with 5x5 bits). Finally, ```maxCorrectionBits``` is
424423
the maximum number of erroneous bits that can be corrected during the marker detection. If this value is too
425424
high, it can lead to a high amount of false positives.
@@ -431,7 +430,7 @@ Fortunately, a marker can be easily transformed to this form using the static me
431430

432431
For example:
433432

434-
``` c++
433+
@code{.cpp}
435434
cv::aruco::Dictionary dictionary;
436435
// markers of 6x6 bits
437436
dictionary.markerSize = 6;
@@ -448,8 +447,7 @@ For example:
448447
// add the marker as a new row
449448
dictionary.bytesList.push_back(markerCompressed);
450449
}
451-
452-
```
450+
@endcode
453451

454452

455453

0 commit comments

Comments
 (0)