Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CharuCo slowdown #25507

Open
wants to merge 1 commit into
base: 4.x
Choose a base branch
from

Conversation

jan-jachnik-oxa
Copy link

@jan-jachnik-oxa jan-jachnik-oxa commented Apr 29, 2024

Fixes #25188

Several functions were returning by value, rather than reference, which was creating unnecessary copies within for loops and seriously affecting the performance of Charuco detection.

Using the benchmarking app referenced in the linked issue, we can see the speed up with the changes:

Return by value

Testing new api
Number of Aruco markers detected: 204
Number of Charuco corners detected: 368
Time to detect markers: 0.053611095600000006
Time to detect charuco: 0.0427095

Return by reference:

Testing new api
Number of Aruco markers detected: 204
Number of Charuco corners detected: 368
Time to detect markers: 0.054944104199999996
Time to detect charuco: 0.0050371666

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

Several functions were returning by value, rather than reference, which was creating unnecessary copies within for loops and seriously affecting the performance of Charuco detection.
@jan-jachnik-oxa
Copy link
Author

The build fails on the "Compare ABI dumps" stage:
image

If this is a hard blocker then I think we'd have to make new functions that return by reference for use inside the detection algorithm and keep the return by value versions for backwards compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Charuco detection has slowed down considerably since 4.6.0
1 participant