Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@AleksandrPanov
Copy link
Contributor

@AleksandrPanov AleksandrPanov commented Oct 3, 2023

Fixes #24113
cornerRefinementMethod=CORNER_REFINE_SUBPIX does not work correctly with markers that are too close to each other.

Now cornerRefinementWinSize is recalculated for each marker as:
cornerRefinementWinSize = min(cornerRefinementWinSize, averageArucoPinSize*relativeCornerRefinmentWinSize)
relativeCornerRefinmentWinSize=0.3 by default and could be changed

image

Also the method has been tested by the benchmark, 289 aruco boards like this were tested:

perspective_none_gaussNoise_33

command line to generate and run (also need set cornerRefinementMethod: 1 and cornerRefinementWinSize: 10 in aruco_params.yml):

objdetect_benchmark.py --marker_length_rate=0.1 --board_x=6 -p=res --rel_center_y=0.53 --rel_center_x=0.56 --synthetic_object=aruco

tested with cornerRefinementWinSize=10
error in pixels with old cornerRefinementMethod:
image
mean detected error in pixels 5.912010732442689

error in pixels with new cornerRefinementMethod:
image
mean detected error in pixels 0.991642490414958

command line to show histogram:

--configuration=show -d1=old.json --marker_length_rate=0.1 --board_x=6 -p=res --rel_center_y=0.53 --rel_center_x=0.56 --synthetic_object=aruco

new.json.txt
old.json.txt

Pull Request Readiness Checklist

See details at https://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 another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the 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

@asmorkalov asmorkalov added this to the 4.9.0 milestone Oct 3, 2023
@AleksandrPanov AleksandrPanov force-pushed the dynamic_window_in_aruco_cornerRefinement branch from 2438a78 to 6b1e3b0 Compare October 6, 2023 00:00
@AleksandrPanov AleksandrPanov marked this pull request as ready for review October 6, 2023 00:38
* In the case of markers located far from each other, it may be useful to increase the value of the parameter to 0.4-0.5.
* In the case of markers located close to each other, it may be useful to decrease the parameter value to 0.1-0.2.
*/
CV_PROP_RW float minCornerRefinementWinSizeInPin;
Copy link
Contributor

Choose a reason for hiding this comment

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

I propose to name the field as relativeCornerRefinmentWinSize. And add information about avarage Aruco pin size and logic to the description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed to relativeCornerRefinmentWinSize:

    /** @brief minimum allowed window size for the corner refinement process (in pins of ArUco marker) (default 0.3).
     *
     * cornerRefinementWinSize is recalculated for each marker as:
     * cornerRefinementWinSize = min(cornerRefinementWinSize, averageArucoModuleSize*relativeCornerRefinmentWinSize),
     * where averageArucoModuleSize is average module size of ArUco marker in pixels.
     * (ArUco marker is composed of black and white modules)
     * In the case of markers located far from each other, it may be useful to increase the value of the parameter to 0.4-0.5.
     * In the case of markers located close to each other, it may be useful to decrease the parameter value to 0.1-0.2.
     */
    CV_PROP_RW float relativeCornerRefinmentWinSize;

@AleksandrPanov
Copy link
Contributor Author

aruco_params.yml.txt

@AleksandrPanov AleksandrPanov force-pushed the dynamic_window_in_aruco_cornerRefinement branch from 6b1e3b0 to 663f4ba Compare October 6, 2023 13:00
@AleksandrPanov AleksandrPanov force-pushed the dynamic_window_in_aruco_cornerRefinement branch from 663f4ba to fd4af21 Compare October 6, 2023 13:44
Copy link
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

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

👍

@victor1234
Copy link
Contributor

@AleksandrPanov what is the peak at 10px?

@AleksandrPanov
Copy link
Contributor Author

AleksandrPanov commented Oct 16, 2023

@victor1234, all markers detected with an error of 10 pixels or more are marked as undetected. These markers make a peak of 10 pixels. The error calculate as the Chebyshev distance between the gold marker and the detected marker.
detected: 10359 markers, total: 10368 markers

@victor1234
Copy link
Contributor

Chebyshev distance

I would say that mean error (=1px) on synthetic data for subpixel method is high. And outliers with error > 1 are also look strange. Do you know the reason?

@asmorkalov
Copy link
Contributor

Several groups of images are blured. Also the benchmark adds color noise on top of the image like pepper-solt augmentation. Current hypothesis is related to this. We make experiments right now and analyze the detector code to prove it.

@asmorkalov asmorkalov mentioned this pull request Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect aruco board corners refinement with CORNER_REFINE_SUBPIX

3 participants