Skip to content

Commit 9ca37bd

Browse files
author
AleksandrPanov
committed
fix charuco_detection.markdown
1 parent 7e1b089 commit 9ca37bd

File tree

5 files changed

+180
-409
lines changed

5 files changed

+180
-409
lines changed
Lines changed: 18 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,5 @@
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-
401
#include <opencv2/highgui.hpp>
41-
#include <opencv2/aruco/charuco.hpp>
2+
#include <opencv2/objdetect/charuco_detector.hpp>
423
#include <iostream>
434
#include "aruco_samples_utility.hpp"
445

@@ -48,11 +9,11 @@ namespace {
489
const char* about = "Create a ChArUco board image";
4910
//! [charuco_detect_board_keys]
5011
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) }"
5617
"{d | | dictionary: DICT_4X4_50=0, DICT_4X4_100=1, DICT_4X4_250=2,"
5718
"DICT_4X4_1000=3, DICT_5X5_50=4, DICT_5X5_100=5, DICT_5X5_250=6, DICT_5X5_1000=7, "
5819
"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 =
6829
int main(int argc, char *argv[]) {
6930
CommandLineParser parser(argc, argv, keys);
7031
parser.about(about);
71-
72-
if(argc < 7) {
32+
if (argc == 1) {
7333
parser.printMessage();
74-
return 0;
7534
}
7635

7736
int squaresX = parser.get<int>("w");
@@ -86,14 +45,14 @@ int main(int argc, char *argv[]) {
8645
int borderBits = parser.get<int>("bb");
8746
bool showImage = parser.get<bool>("si");
8847

89-
String out = parser.get<String>(0);
48+
std::string pathOutImg = parser.get<std::string>(0);
9049

9150
if(!parser.check()) {
9251
parser.printErrors();
9352
return 0;
9453
}
9554

96-
aruco::Dictionary dictionary = aruco::getPredefinedDictionary(0);
55+
aruco::Dictionary dictionary = aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50);
9756
if (parser.has("d")) {
9857
int dictionaryId = parser.get<int>("d");
9958
dictionary = aruco::getPredefinedDictionary(aruco::PredefinedDictionaryType(dictionaryId));
@@ -107,26 +66,30 @@ int main(int argc, char *argv[]) {
10766
}
10867
}
10968
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;
11271
}
11372

11473
Size imageSize;
11574
imageSize.width = squaresX * squareLength + 2 * margins;
11675
imageSize.height = squaresY * squareLength + 2 * margins;
11776

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]
11980

12081
// show created board
82+
//! [generate_charucoBoard]
12183
Mat boardImage;
12284
board.generateImage(imageSize, boardImage, margins, borderBits);
85+
//! [generate_charucoBoard]
12386

12487
if(showImage) {
12588
imshow("board", boardImage);
12689
waitKey(0);
12790
}
12891

129-
imwrite(out, boardImage);
130-
92+
if (pathOutImg != "")
93+
imwrite(pathOutImg, boardImage);
13194
return 0;
13295
}

0 commit comments

Comments
 (0)