Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged

Conversation

@AleksandrPanov
Copy link
Contributor

@AleksandrPanovAleksandrPanov commentedDec 2, 2021
edited
Loading

Some ArUco tutorial examples (Detection of ArUco Boards and Detection of ChArUco Corners) aren't reproduced:

  • gboriginal.png // need custom dictionary to detect markers
  • choriginal.png // need custom dictionary and custom board configuration to detect markers
  • diamondmarkers.png // need custom dictionary and custom detector parameters to detect all markers

This PR:

  • fix detection ofgboriginal.png anddiamondmarkers.png by using custom dictionary fromoriginal lib (filetutorial_dict.yml) and custom detector parameters (the required flags have been added to the examples).
  • detection ofchoriginal.png can't be fixed easy. So, images of ChArUco board are recaptured:
New ChArUco board images

choriginal

chaxis

chocclusion_original

chocclusion_axis

Also this PR:

  • Add to ArUco API:readDetectorParameters() andreadDictionary().
  • Addsamples_utility.hpp withreadCameraParameters(),saveCameraParams().
  • Add tests of tutorial to avoid regression:can_find_singlemarkersoriginal,can_find_gboriginal,can_find_choriginal,can_find_chocclusion,can_find_diamondmarkers.
  • Add custom dictionarytutorial_dict.yml andtutorial_camera_params.yml.
  • Add ChArUco calibration samples:
calibration samples

img_00

img_01

img_02

img_03

  • Addtutorial_camera_charuco.yml (created bycalibrate_camera_charuco.cpp and calibration samples).
  • Add prev/next links.
  • Check and update flags for samples.
  • Add some snippets.

Pull Request Readiness Checklist

See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • 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

@AleksandrPanovAleksandrPanovforce-pushed theupdate_ArUco_tutorial branch 9 times, most recently from5fd0f91 todeaa392CompareDecember 8, 2021 13:40
@AleksandrPanovAleksandrPanov added category: documentationDocumentation fix or update, does not affect code category: samples category: aruco labelsDec 8, 2021
@AleksandrPanovAleksandrPanovforce-pushed theupdate_ArUco_tutorial branch 3 times, most recently from13ff2da to2c618f8CompareDecember 8, 2021 16:41
@AleksandrPanovAleksandrPanov marked this pull request as ready for reviewDecember 8, 2021 16:43
@AleksandrPanovAleksandrPanovforce-pushed theupdate_ArUco_tutorial branch 2 times, most recently from894f98d toe2a3014CompareDecember 10, 2021 09:00
@AleksandrPanovAleksandrPanov marked this pull request as draftDecember 10, 2021 09:58
@AleksandrPanovAleksandrPanovforce-pushed theupdate_ArUco_tutorial branch 2 times, most recently from5b6b44f to3d855aaCompareDecember 10, 2021 14:48
@AleksandrPanovAleksandrPanov marked this pull request as ready for reviewDecember 10, 2021 16:02
@AleksandrPanov
Copy link
ContributorAuthor

@alalek,@asmorkalov,@mshabunin, could you review this PR?

@AleksandrPanovAleksandrPanovforce-pushed theupdate_ArUco_tutorial branch 4 times, most recently from03fc10f to9f2b371CompareDecember 14, 2021 22:45
@asmorkalov
Copy link
Contributor

@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.
Copy link
Member

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.

Copy link
ContributorAuthor

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_
Copy link
Member

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.

Copy link
ContributorAuthor

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

inline -> static

Copy link
ContributorAuthor

@AleksandrPanovAleksandrPanovDec 15, 2021
edited
Loading

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?

Copy link
ContributorAuthor

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.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

image

Copy link
ContributorAuthor

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?

Copy link
Member

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.

Copy link
ContributorAuthor

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)

Copy link
ContributorAuthor

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"
Copy link
Member

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"

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

fixed


//! [detwcp]
voiddetectCharucoBoardWithCalibrationPose()
inlinevoiddetectCharucoBoardWithCalibrationPose()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

static

Copy link
ContributorAuthor

@AleksandrPanovAleksandrPanovDec 15, 2021
edited
Loading

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

precomp must go first.

Copy link
ContributorAuthor

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"
Copy link
Member

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.

Copy link
ContributorAuthor

@AleksandrPanovAleksandrPanovDec 15, 2021
edited
Loading

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.

Copy link
ContributorAuthor

@AleksandrPanovAleksandrPanovDec 15, 2021
edited
Loading

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.

Copy link
ContributorAuthor

@AleksandrPanovAleksandrPanovDec 16, 2021
edited
Loading

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:

  1. addreadDetectorParameters() to ArUco API
  2. addreadDictionary() to ArUco API
  3. removearuco_samples_utility.hpp
  4. just reinsertreadCameraParameters() andsaveCameraParams() to samples/tests code.

Would it be ok?

alalek reacted with thumbs up emoji
Copy link
Member

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).

AleksandrPanov reacted with thumbs up emoji
Copy link
ContributorAuthor

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;}

Copy link
Member

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.

Copy link
ContributorAuthor

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);
Copy link
Member

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.

Copy link
ContributorAuthor

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

@AleksandrPanovAleksandrPanovforce-pushed theupdate_ArUco_tutorial branch 2 times, most recently from48d852d to63ad95aCompareDecember 15, 2021 14:41
}

template<typename T>
inlinevoidreadParameter(FileNode node, T& parameter)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

static inline

Copy link
ContributorAuthor

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Avoid indentation in namespaces.

Copy link
ContributorAuthor

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"
Copy link
Member

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"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

fs.root()?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

fixed

@AleksandrPanovAleksandrPanovforce-pushed theupdate_ArUco_tutorial branch 2 times, most recently fromc3e1180 to5bbda1cCompareDecember 17, 2021 16:56
@AleksandrPanov
Copy link
ContributorAuthor

@alalek, thx for review ^_^
As I think, all issues were fixed

…tion photos, add tests, add aruco_samples_utility.hpp
@AleksandrPanov
Copy link
ContributorAuthor

@alalek could you check?

Copy link
Member

@alalekalalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM 👍

@opencv-pushbotopencv-pushbot merged commite0db5fd intoopencv:3.4Dec 20, 2021
@alalekalalek mentioned this pull requestDec 22, 2021
@alalekalalek mentioned this pull requestDec 30, 2021
@alalekalalek mentioned this pull requestFeb 22, 2022
@AleksandrPanovAleksandrPanov deleted the update_ArUco_tutorial branchMarch 18, 2022 12:58
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@asmorkalovasmorkalovasmorkalov approved these changes

@alalekalalekalalek approved these changes

Assignees

@asmorkalovasmorkalov

Labels

category: arucocategory: documentationDocumentation fix or update, does not affect codecategory: samplesfeaturetest

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@AleksandrPanov@asmorkalov@alalek@opencv-pushbot

[8]ページ先頭

©2009-2025 Movatter.jp