mirror of
https://github.com/opencv/opencv.git
synced 2026-07-25 21:33:04 +04:00
Merge pull request #25378 from AleksandrPanov:move_charuco_tutorial
Move Charuco/Calib tutorials and samples to main repo #25378 Merge with https://github.com/opencv/opencv_contrib/pull/3708 Move Charuco/Calib tutorials and samples to main repo: - [x] update/fix charuco_detection.markdown and samples - [x] update/fix charuco_diamond_detection.markdown and samples - [x] update/fix aruco_calibration.markdown and samples - [x] update/fix aruco_faq.markdown - [x] move tutorials, samples and tests to main repo - [x] remove old tutorials, samples and tests from contrib ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -30,46 +30,6 @@ const char* keys =
|
||||
}
|
||||
//! [aruco_detect_board_keys]
|
||||
|
||||
static void readDetectorParamsFromCommandLine(CommandLineParser &parser, aruco::DetectorParameters& detectorParams) {
|
||||
if(parser.has("dp")) {
|
||||
FileStorage fs(parser.get<string>("dp"), FileStorage::READ);
|
||||
bool readOk = detectorParams.readDetectorParameters(fs.root());
|
||||
if(!readOk) {
|
||||
cerr << "Invalid detector parameters file" << endl;
|
||||
throw -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void readCameraParamsFromCommandLine(CommandLineParser &parser, Mat& camMatrix, Mat& distCoeffs) {
|
||||
if(parser.has("c")) {
|
||||
bool readOk = readCameraParameters(parser.get<string>("c"), camMatrix, distCoeffs);
|
||||
if(!readOk) {
|
||||
cerr << "Invalid camera file" << endl;
|
||||
throw -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void readDictionatyFromCommandLine(CommandLineParser &parser, aruco::Dictionary& dictionary) {
|
||||
if (parser.has("d")) {
|
||||
int dictionaryId = parser.get<int>("d");
|
||||
dictionary = aruco::getPredefinedDictionary(aruco::PredefinedDictionaryType(dictionaryId));
|
||||
}
|
||||
else if (parser.has("cd")) {
|
||||
FileStorage fs(parser.get<string>("cd"), FileStorage::READ);
|
||||
bool readOk = dictionary.readDictionary(fs.root());
|
||||
if(!readOk) {
|
||||
cerr << "Invalid dictionary file" << endl;
|
||||
throw -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
cerr << "Dictionary not specified" << endl;
|
||||
throw -1;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
CommandLineParser parser(argc, argv, keys);
|
||||
parser.about(about);
|
||||
@@ -91,10 +51,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
Mat camMatrix, distCoeffs;
|
||||
readCameraParamsFromCommandLine(parser, camMatrix, distCoeffs);
|
||||
|
||||
aruco::DetectorParameters detectorParams;
|
||||
detectorParams.cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX; // do corner refinement in markers
|
||||
readDetectorParamsFromCommandLine(parser, detectorParams);
|
||||
aruco::Dictionary dictionary = readDictionatyFromCommandLine(parser);
|
||||
aruco::DetectorParameters detectorParams = readDetectorParamsFromCommandLine(parser);
|
||||
|
||||
String video;
|
||||
if(parser.has("v")) {
|
||||
@@ -106,9 +64,6 @@ int main(int argc, char *argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
aruco::Dictionary dictionary = aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50);
|
||||
readDictionatyFromCommandLine(parser, dictionary);
|
||||
|
||||
aruco::ArucoDetector detector(dictionary, detectorParams);
|
||||
VideoCapture inputVideo;
|
||||
int waitTime;
|
||||
@@ -181,9 +136,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// Draw results
|
||||
image.copyTo(imageCopy);
|
||||
if(!ids.empty()) {
|
||||
if(!ids.empty())
|
||||
aruco::drawDetectedMarkers(imageCopy, corners, ids);
|
||||
}
|
||||
|
||||
if(showRejected && !rejected.empty())
|
||||
aruco::drawDetectedMarkers(imageCopy, rejected, noArray(), Scalar(100, 0, 255));
|
||||
|
||||
Reference in New Issue
Block a user