1
- /*
2
- By downloading, copying, installing or using the software you agree to this
3
- license. If you do not agree to this license, do not download, install,
4
- copy or use the software.
5
-
6
- License Agreement
7
- For Open Source Computer Vision Library
8
- (3-clause BSD License)
9
-
10
- Copyright (C) 2013, OpenCV Foundation, all rights reserved.
11
- Third party copyrights are property of their respective owners.
12
-
13
- Redistribution and use in source and binary forms, with or without modification,
14
- are permitted provided that the following conditions are met:
15
-
16
- * Redistributions of source code must retain the above copyright notice,
17
- this list of conditions and the following disclaimer.
18
-
19
- * Redistributions in binary form must reproduce the above copyright notice,
20
- this list of conditions and the following disclaimer in the documentation
21
- and/or other materials provided with the distribution.
22
-
23
- * Neither the names of the copyright holders nor the names of the contributors
24
- may be used to endorse or promote products derived from this software
25
- without specific prior written permission.
26
-
27
- This software is provided by the copyright holders and contributors "as is" and
28
- any express or implied warranties, including, but not limited to, the implied
29
- warranties of merchantability and fitness for a particular purpose are
30
- disclaimed. In no event shall copyright holders or contributors be liable for
31
- any direct, indirect, incidental, special, exemplary, or consequential damages
32
- (including, but not limited to, procurement of substitute goods or services;
33
- loss of use, data, or profits; or business interruption) however caused
34
- and on any theory of liability, whether in contract, strict liability,
35
- or tort (including negligence or otherwise) arising in any way out of
36
- the use of this software, even if advised of the possibility of such damage.
37
- */
38
-
39
-
40
1
#include < opencv2/highgui.hpp>
41
- #include < opencv2/aruco/charuco .hpp>
2
+ #include < opencv2/objdetect/charuco_detector .hpp>
42
3
#include < iostream>
43
4
#include " aruco_samples_utility.hpp"
44
5
@@ -48,11 +9,11 @@ namespace {
48
9
const char * about = " Create a ChArUco board image" ;
49
10
// ! [charuco_detect_board_keys]
50
11
const char * keys =
51
- " {@outfile |<none> | Output image }"
52
- " {w | | Number of squares in X direction }"
53
- " {h | | Number of squares in Y direction }"
54
- " {sl | | Square side length (in pixels) }"
55
- " {ml | | Marker side length (in pixels) }"
12
+ " {@outfile |res.png | Output image }"
13
+ " {w | 5 | Number of squares in X direction }"
14
+ " {h | 7 | Number of squares in Y direction }"
15
+ " {sl | 100 | Square side length (in pixels) }"
16
+ " {ml | 60 | Marker side length (in pixels) }"
56
17
" {d | | dictionary: DICT_4X4_50=0, DICT_4X4_100=1, DICT_4X4_250=2,"
57
18
" DICT_4X4_1000=3, DICT_5X5_50=4, DICT_5X5_100=5, DICT_5X5_250=6, DICT_5X5_1000=7, "
58
19
" DICT_6X6_50=8, DICT_6X6_100=9, DICT_6X6_250=10, DICT_6X6_1000=11, DICT_7X7_50=12,"
@@ -68,10 +29,8 @@ const char* keys =
68
29
int main (int argc, char *argv[]) {
69
30
CommandLineParser parser (argc, argv, keys);
70
31
parser.about (about);
71
-
72
- if (argc < 7 ) {
32
+ if (argc == 1 ) {
73
33
parser.printMessage ();
74
- return 0 ;
75
34
}
76
35
77
36
int squaresX = parser.get <int >(" w" );
@@ -86,14 +45,14 @@ int main(int argc, char *argv[]) {
86
45
int borderBits = parser.get <int >(" bb" );
87
46
bool showImage = parser.get <bool >(" si" );
88
47
89
- String out = parser.get <String >(0 );
48
+ std::string pathOutImg = parser.get <std::string >(0 );
90
49
91
50
if (!parser.check ()) {
92
51
parser.printErrors ();
93
52
return 0 ;
94
53
}
95
54
96
- aruco::Dictionary dictionary = aruco::getPredefinedDictionary (0 );
55
+ aruco::Dictionary dictionary = aruco::getPredefinedDictionary (cv::aruco::DICT_4X4_50 );
97
56
if (parser.has (" d" )) {
98
57
int dictionaryId = parser.get <int >(" d" );
99
58
dictionary = aruco::getPredefinedDictionary (aruco::PredefinedDictionaryType (dictionaryId));
@@ -107,26 +66,30 @@ int main(int argc, char *argv[]) {
107
66
}
108
67
}
109
68
else {
110
- std::cerr << " Dictionary not specified " << std::endl;
111
- return 0 ;
69
+ std::cout << " The default DICT_4X4_50 dictionary has been selected, you could "
70
+ " select the specific dictionary using flags -d or -cd. " << std::endl ;
112
71
}
113
72
114
73
Size imageSize;
115
74
imageSize.width = squaresX * squareLength + 2 * margins;
116
75
imageSize.height = squaresY * squareLength + 2 * margins;
117
76
118
- aruco::CharucoBoard board (Size (squaresX, squaresY), (float )squareLength, (float )markerLength, dictionary);
77
+ // ! [create_charucoBoard]
78
+ cv::aruco::CharucoBoard board (Size (squaresX, squaresY), (float )squareLength, (float )markerLength, dictionary);
79
+ // ! [create_charucoBoard]
119
80
120
81
// show created board
82
+ // ! [generate_charucoBoard]
121
83
Mat boardImage;
122
84
board.generateImage (imageSize, boardImage, margins, borderBits);
85
+ // ! [generate_charucoBoard]
123
86
124
87
if (showImage) {
125
88
imshow (" board" , boardImage);
126
89
waitKey (0 );
127
90
}
128
91
129
- imwrite (out, boardImage);
130
-
92
+ if (pathOutImg != " " )
93
+ imwrite (pathOutImg, boardImage);
131
94
return 0 ;
132
95
}
0 commit comments