- Notifications
You must be signed in to change notification settings - Fork5.9k
Update ArUco tutorial#3126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
5fd0f91 todeaa392Compare13ff2da to2c618f8Compare2c618f8 to175c508Compare894f98d toe2a3014Compare5b6b44f to3d855aaCompareAleksandrPanov commentedDec 10, 2021
@alalek,@asmorkalov,@mshabunin, could you review this PR? |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
03fc10f to9f2b371CompareUh oh!
There was an error while loading.Please reload this page.
9f2b371 to50dc184Compareasmorkalov commentedDec 15, 2021
@alalek could you look and merge. |
| @@ -0,0 +1,110 @@ | |||
| // This file is part of OpenCV project. | |||
| // It is subject to the license terms in the LICENSE file found in the top-level directory | |||
| // of this distribution and at http://opencv.org/license.html. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Samples doesn't have license header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fixed
| // of this distribution and at http://opencv.org/license.html. | ||
| #ifndef _SAMPLES_UTILITY_HPP_ | ||
| #define_SAMPLES_UTILITY_HPP_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We don't need guard here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fixed
| #include<opencv2/calib3d.hpp> | ||
| #include<ctime> | ||
| inlineboolreadCameraParameters(std::string filename, cv::Mat &camMatrix, cv::Mat &distCoeffs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
inline -> static
AleksandrPanovDec 15, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
CI throw warning to static functions:warning: defined but not used [-Wunused-function]
what to do in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Because not every sample uses all functions from samples_utility.hpp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Maybe I should usestatic inline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
These attached messages comes from tests compilation, not sample code.
Anonymous namespace may help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Anonymous namespace didn't help ((( (warnings are still there due to tests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fixed
include ofaruco_samples_utility.hpp is removed from tests
| #include<vector> | ||
| #include<iostream> | ||
| #include<ctime> | ||
| #include"samples_utility.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
"samples_utility.hpp" -> "aruco_samples_utility.hpp"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fixed
| //! [detwcp] | ||
| voiddetectCharucoBoardWithCalibrationPose() | ||
| inlinevoiddetectCharucoBoardWithCalibrationPose() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
static
AleksandrPanovDec 15, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
addstatic inline to avoid warning:defined but not used [-Wunused-function]
| #include<opencv2/core/utils/logger.defines.hpp> | ||
| #include"test_precomp.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
precomp must go first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fixed
| #include<opencv2/core/utils/logger.defines.hpp> | ||
| #include"test_precomp.hpp" | ||
| #include"../samples/samples_utility.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Test should not rely on samples code.
Samples code should not be over-complicated by tests specific.
AleksandrPanovDec 15, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I need functions fromsamples_utility.hpp to advoid code duplication in tests.
AleksandrPanovDec 15, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Also some ArUco samples just don't work (in 3.4/4.x). Maybe using functions in a test will allow CI to check workability of samples.
I understand, that "test should not rely on samples code". But I don't know how check workability of samples in this case.
AleksandrPanovDec 16, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@alalek I can do this:
- add
readDetectorParameters()to ArUco API - add
readDictionary()to ArUco API - remove
aruco_samples_utility.hpp - just reinsert
readCameraParameters()andsaveCameraParams()to samples/tests code.
Would it be ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It makes sense (usingcv::FileNode instead ofstd::string).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@alalek it should look something like this?
template<typename T>inline void readParameter(FileNode node, T& parameter){ if (!node.empty()) node >> parameter;}/** * @brief Read a new set of DetectorParameters from FileStorage. */Ptr<DetectorParameters> DetectorParameters::readDetectorParameters(const Ptr<FileStorage>& pfs){ CV_Assert(!pfs.empty()); const FileStorage& fs = *pfs; Ptr<DetectorParameters> params = DetectorParameters::create(); readParameter(fs["adaptiveThreshWinSizeMin"], params->adaptiveThreshWinSizeMin); readParameter(fs["adaptiveThreshWinSizeMax"], params->adaptiveThreshWinSizeMax); readParameter(fs["adaptiveThreshWinSizeStep"], params->adaptiveThreshWinSizeStep); readParameter(fs["adaptiveThreshConstant"], params->adaptiveThreshConstant); readParameter(fs["minMarkerPerimeterRate"], params->minMarkerPerimeterRate); readParameter(fs["maxMarkerPerimeterRate"], params->maxMarkerPerimeterRate); readParameter(fs["polygonalApproxAccuracyRate"], params->polygonalApproxAccuracyRate); readParameter(fs["minCornerDistanceRate"], params->minCornerDistanceRate); readParameter(fs["minDistanceToBorder"], params->minDistanceToBorder); readParameter(fs["minMarkerDistanceRate"], params->minMarkerDistanceRate); readParameter(fs["cornerRefinementMethod"], params->cornerRefinementMethod); readParameter(fs["cornerRefinementWinSize"], params->cornerRefinementWinSize); readParameter(fs["cornerRefinementMaxIterations"], params->cornerRefinementMaxIterations); readParameter(fs["cornerRefinementMinAccuracy"], params->cornerRefinementMinAccuracy); readParameter(fs["markerBorderBits"], params->markerBorderBits); readParameter(fs["perspectiveRemovePixelPerCell"], params->perspectiveRemovePixelPerCell); readParameter(fs["perspectiveRemoveIgnoredMarginPerCell"], params->perspectiveRemoveIgnoredMarginPerCell); readParameter(fs["maxErroneousBitsInBorderRate"], params->maxErroneousBitsInBorderRate); readParameter(fs["minOtsuStdDev"], params->minOtsuStdDev); readParameter(fs["errorCorrectionRate"], params->errorCorrectionRate); return params;}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
FileNode node
const reference.
Ptr<FileStorage>&
FileNode instead of FileStorage as mentioned before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fixed
| TEST(CV_ArucoTutorial, can_find_singlemarkersoriginal) | ||
| { | ||
| string img_path =samples::findFile("../opencv_contrib/modules/aruco/tutorials/aruco_detection/images" | ||
| "/singlemarkersoriginal.jpg",true,true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
samples::findFile
Test code should not use samples data.
../opencv_contrib/modules
Wrong way.
Check "text" module tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fixed!)
checkopencv_contrib/modules/aruco/CMakeLists.txt
48d852d to63ad95aComparemodules/aruco/src/aruco.cpp Outdated
| } | ||
| template<typename T> | ||
| inlinevoidreadParameter(FileNode node, T& parameter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
static inline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fixed
| #include<ctime> | ||
| namespace { | ||
| inlinestaticboolreadCameraParameters(std::string filename, cv::Mat &camMatrix, cv::Mat &distCoeffs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Avoid indentation in namespaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fixed
| #include<opencv2/core/utils/logger.defines.hpp> | ||
| #include"test_precomp.hpp" | ||
| #include"../samples/samples_utility.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
FileNode node
const reference.
Ptr<FileStorage>&
FileNode instead of FileStorage as mentioned before.
| return0; | ||
| } | ||
| FileStoragefs(parser.get<string>("dp"), FileStorage::READ); | ||
| detectorParams =aruco::DetectorParameters::readDetectorParameters(fs["aruco_detector_params"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fs.root()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fixed
c3e1180 to5bbda1cCompareAleksandrPanov commentedDec 17, 2021
@alalek, thx for review ^_^ |
…tion photos, add tests, add aruco_samples_utility.hpp
5bbda1c toa965b9bCompareAleksandrPanov commentedDec 20, 2021
@alalek could you check? |
alalek left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM 👍

Uh oh!
There was an error while loading.Please reload this page.
Some ArUco tutorial examples (Detection of ArUco Boards and Detection of ChArUco Corners) aren't reproduced:
This PR:
tutorial_dict.yml) and custom detector parameters (the required flags have been added to the examples).New ChArUco board images
Also this PR:
readDetectorParameters()andreadDictionary().samples_utility.hppwithreadCameraParameters(),saveCameraParams().can_find_singlemarkersoriginal,can_find_gboriginal,can_find_choriginal,can_find_chocclusion,can_find_diamondmarkers.tutorial_dict.ymlandtutorial_camera_params.yml.calibration samples
tutorial_camera_charuco.yml(created bycalibrate_camera_charuco.cppand calibration samples).Pull Request Readiness Checklist
See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.