Skip to content

Replace OpenCV version string comparison with semver. (backport #1087) #1089

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

Merged
merged 2 commits into from
Apr 22, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Apr 21, 2025

When using the ChArUco markers with cameracalibrator, I found out that there's an issue with the last versions of OpenCV due to the fact that versions are compared as strings and the thing goes wrong for versions 4.10 and above e.g.:

>>> '4.7.0' >= '4.8.0'
False
>>> '4.8.0' >= '4.8.0'
True
>>> '4.9.0' >= '4.8.0'
True
>>> '4.10.0' >= '4.8.0'
False
>>> '4.11.0' >= '4.8.0'
False

I fixed the behavior by using semver library which is already used in the package e.g.:

>>> VersionInfo.parse('4.7.0') >= VersionInfo.parse('4.8.0')
False
>>> VersionInfo.parse('4.8.0') >= VersionInfo.parse('4.8.0')
True
>>> VersionInfo.parse('4.9.0') >= VersionInfo.parse('4.8.0')
True
>>> VersionInfo.parse('4.10.0') >= VersionInfo.parse('4.8.0')
True
>>> VersionInfo.parse('4.11.0') >= VersionInfo.parse('4.8.0')
True

Hope this fix helps anyone else too despite the fact that documentation/tutorials are skipping to mention the ChArUcos as a possible pattern (like here). In my experience, ChArUcos give better results than classic chessboards.

Also a question: does anyone mind if I cherry-pick this fix here along with mine above also to the humble?


This is an automatic backport of pull request #1087 done by Mergify.

Copy link
Contributor Author

mergify bot commented Apr 21, 2025

Cherry-pick of 2e10964 has failed:

On branch mergify/bp/humble/pr-1087
Your branch is up to date with 'origin/humble'.

You are currently cherry-picking commit 2e10964.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   camera_calibration/src/camera_calibration/calibrator.py

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
@ahcorde ahcorde force-pushed the mergify/bp/humble/pr-1087 branch from 3aaca14 to e70ed72 Compare April 21, 2025 08:22
Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
@ahcorde ahcorde merged commit 8b003f3 into humble Apr 22, 2025
3 checks passed
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.

2 participants