Skip to content

Commit 882d7e6

Browse files
committed
Merge pull request #1637 from catree:add_apriltag_dictionaries
2 parents c540409 + 81d7d98 commit 882d7e6

File tree

6 files changed

+14960
-10
lines changed

6 files changed

+14960
-10
lines changed

modules/aruco/doc/aruco.bib

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@article{Aruco2014,
2+
title = "Automatic generation and detection of highly reliable fiducial markers under occlusion ",
3+
journal = "Pattern Recognition ",
4+
volume = "47",
5+
number = "6",
6+
pages = "2280 - 2292",
7+
year = "2014",
8+
issn = "0031-3203",
9+
doi = "http://dx.doi.org/10.1016/j.patcog.2014.01.005",
10+
url = "http://www.sciencedirect.com/science/article/pii/S0031320314000235",
11+
author = "S. Garrido-Jurado and R. Mu\~noz-Salinas and F.J. Madrid-Cuevas and M.J. Mar\'in-Jim\'enez"
12+
}
13+
14+
@inproceedings{wang2016iros,
15+
AUTHOR = {John Wang and Edwin Olson},
16+
TITLE = {{AprilTag} 2: Efficient and robust fiducial detection},
17+
BOOKTITLE = {Proceedings of the {IEEE/RSJ} International Conference on Intelligent
18+
Robots and Systems {(IROS)}},
19+
YEAR = {2016},
20+
MONTH = {October},
21+
}

modules/aruco/include/opencv2/aruco.hpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,16 @@ the use of this software, even if advised of the possibility of such damage.
4949
* These markers are useful for easy, fast and robust camera pose estimation.ç
5050
*
5151
* The main functionalities are:
52-
* - Detection of markers in a image
52+
* - Detection of markers in an image
5353
* - Pose estimation from a single marker or from a board/set of markers
5454
* - Detection of ChArUco board for high subpixel accuracy
5555
* - Camera calibration from both, ArUco boards and ChArUco boards.
5656
* - Detection of ChArUco diamond markers
5757
* The samples directory includes easy examples of how to use the module.
5858
*
59-
* The implementation is based on the ArUco Library by R. Muñoz-Salinas and S. Garrido-Jurado.
59+
* The implementation is based on the ArUco Library by R. Muñoz-Salinas and S. Garrido-Jurado @cite Aruco2014.
60+
*
61+
* Markers can also be detected based on the AprilTag 2 @cite wang2016iros fiducial detection method.
6062
*
6163
* @sa S. Garrido-Jurado, R. Muñoz-Salinas, F. J. Madrid-Cuevas, and M. J. Marín-Jiménez. 2014.
6264
* "Automatic generation and detection of highly reliable fiducial markers under occlusion".
@@ -77,10 +79,10 @@ namespace aruco {
7779
//! @{
7880

7981
enum CornerRefineMethod{
80-
CORNER_REFINE_NONE, // default corners
81-
CORNER_REFINE_SUBPIX, // refine the corners using subpix
82-
CORNER_REFINE_CONTOUR, // refine the corners using the contour-points
83-
CORNER_REFINE_APRILTAG, // detect corners using the AprilTag2 approach
82+
CORNER_REFINE_NONE, ///< Tag and corners detection based on the ArUco approach
83+
CORNER_REFINE_SUBPIX, ///< ArUco approach and refine the corners locations using corner subpixel accuracy
84+
CORNER_REFINE_CONTOUR, ///< ArUco approach and refine the corners locations using the contour-points line fitting
85+
CORNER_REFINE_APRILTAG, ///< Tag and corners detection based on the AprilTag 2 approach @cite wang2016iros
8486
};
8587

8688
/**

modules/aruco/include/opencv2/aruco/dictionary.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ enum CV_EXPORTS_W_SIMPLE PREDEFINED_DICTIONARY_NAME {
155155
DICT_7X7_100,
156156
DICT_7X7_250,
157157
DICT_7X7_1000,
158-
DICT_ARUCO_ORIGINAL
158+
DICT_ARUCO_ORIGINAL,
159+
DICT_APRILTAG_16h5, ///< 4x4 bits, minimum hamming distance between any two codes = 5, 30 codes
160+
DICT_APRILTAG_25h9, ///< 5x5 bits, minimum hamming distance between any two codes = 9, 35 codes
161+
DICT_APRILTAG_36h10, ///< 6x6 bits, minimum hamming distance between any two codes = 10, 2320 codes
162+
DICT_APRILTAG_36h11 ///< 6x6 bits, minimum hamming distance between any two codes = 11, 587 codes
159163
};
160164

161165

modules/aruco/samples/detect_markers.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,16 @@ const char* keys =
5050
"{d | | dictionary: DICT_4X4_50=0, DICT_4X4_100=1, DICT_4X4_250=2,"
5151
"DICT_4X4_1000=3, DICT_5X5_50=4, DICT_5X5_100=5, DICT_5X5_250=6, DICT_5X5_1000=7, "
5252
"DICT_6X6_50=8, DICT_6X6_100=9, DICT_6X6_250=10, DICT_6X6_1000=11, DICT_7X7_50=12,"
53-
"DICT_7X7_100=13, DICT_7X7_250=14, DICT_7X7_1000=15, DICT_ARUCO_ORIGINAL = 16}"
53+
"DICT_7X7_100=13, DICT_7X7_250=14, DICT_7X7_1000=15, DICT_ARUCO_ORIGINAL = 16,"
54+
"DICT_APRILTAG_16h5=17, DICT_APRILTAG_25h9=18, DICT_APRILTAG_36h10=19, DICT_APRILTAG_36h11=20}"
5455
"{v | | Input from video file, if ommited, input comes from camera }"
5556
"{ci | 0 | Camera id if input doesnt come from video (-v) }"
5657
"{c | | Camera intrinsic parameters. Needed for camera pose }"
5758
"{l | 0.1 | Marker side lenght (in meters). Needed for correct scale in camera pose }"
5859
"{dp | | File of marker detector parameters }"
59-
"{r | | show rejected candidates too }";
60+
"{r | | show rejected candidates too }"
61+
"{refine | | Corner refinement: CORNER_REFINE_NONE=0, CORNER_REFINE_SUBPIX=1,"
62+
"CORNER_REFINE_CONTOUR=2, CORNER_REFINE_APRILTAG=3}";
6063
}
6164

6265
/**
@@ -127,7 +130,12 @@ int main(int argc, char *argv[]) {
127130
return 0;
128131
}
129132
}
130-
detectorParams->cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX; // do corner refinement in markers
133+
134+
if (parser.has("refine")) {
135+
//override cornerRefinementMethod read from config file
136+
detectorParams->cornerRefinementMethod = parser.get<int>("refine");
137+
}
138+
std::cout << "Corner refinement method (0: None, 1: Subpixel, 2:contour, 3: AprilTag 2): " << detectorParams->cornerRefinementMethod << std::endl;
131139

132140
int camId = parser.get<int>("ci");
133141

modules/aruco/src/dictionary.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ the use of this software, even if advised of the possibility of such damage.
4141
#include <opencv2/core.hpp>
4242
#include <opencv2/imgproc.hpp>
4343
#include "predefined_dictionaries.hpp"
44+
#include "predefined_dictionaries_apriltag.hpp"
4445
#include "opencv2/core/hal/hal.hpp"
4546

4647
namespace cv {
@@ -291,6 +292,11 @@ const Dictionary DICT_7X7_100_DATA = Dictionary(Mat(100, (7*7 + 7)/8 ,CV_8UC4, (
291292
const Dictionary DICT_7X7_250_DATA = Dictionary(Mat(250, (7*7 + 7)/8 ,CV_8UC4, (uchar*)DICT_7X7_1000_BYTES), 7, 8);
292293
const Dictionary DICT_7X7_1000_DATA = Dictionary(Mat(1000, (7*7 + 7)/8 ,CV_8UC4, (uchar*)DICT_7X7_1000_BYTES), 7, 6);
293294

295+
const Dictionary DICT_APRILTAG_16h5_DATA = Dictionary(Mat(30, (4*4 + 7)/8, CV_8UC4, (uchar*)DICT_APRILTAG_16h5_BYTES), 4, 0);
296+
const Dictionary DICT_APRILTAG_25h9_DATA = Dictionary(Mat(35, (5*5 + 7)/8, CV_8UC4, (uchar*)DICT_APRILTAG_25h9_BYTES), 5, 0);
297+
const Dictionary DICT_APRILTAG_36h10_DATA = Dictionary(Mat(2320, (6*6 + 7)/8, CV_8UC4, (uchar*)DICT_APRILTAG_36h10_BYTES), 6, 0);
298+
const Dictionary DICT_APRILTAG_36h11_DATA = Dictionary(Mat(587, (6*6 + 7)/8, CV_8UC4, (uchar*)DICT_APRILTAG_36h11_BYTES), 6, 0);
299+
294300

295301
Ptr<Dictionary> getPredefinedDictionary(PREDEFINED_DICTIONARY_NAME name) {
296302
switch(name) {
@@ -334,6 +340,15 @@ Ptr<Dictionary> getPredefinedDictionary(PREDEFINED_DICTIONARY_NAME name) {
334340
case DICT_7X7_1000:
335341
return makePtr<Dictionary>(DICT_7X7_1000_DATA);
336342

343+
case DICT_APRILTAG_16h5:
344+
return makePtr<Dictionary>(DICT_APRILTAG_16h5_DATA);
345+
case DICT_APRILTAG_25h9:
346+
return makePtr<Dictionary>(DICT_APRILTAG_25h9_DATA);
347+
case DICT_APRILTAG_36h10:
348+
return makePtr<Dictionary>(DICT_APRILTAG_36h10_DATA);
349+
case DICT_APRILTAG_36h11:
350+
return makePtr<Dictionary>(DICT_APRILTAG_36h11_DATA);
351+
337352
}
338353
return makePtr<Dictionary>(DICT_4X4_50_DATA);
339354
}

0 commit comments

Comments
 (0)