Fix ArUco detection under OpenCV 5 - #64
Merged
Merged
Conversation
OpenCV 5.0 (opencv-contrib-python 5.0.0.93, which pip now resolves to)
removed the free `cv2.aruco.detectMarkers` function that was deprecated
when the `ArucoDetector` class was introduced in 4.7. Both call sites in
`fiducial.py` therefore raised
AttributeError: module 'cv2.aruco' has no attribute 'detectMarkers'
failing test_compensation and test_revert_frames_shape. Construct an
`ArucoDetector` from the dictionary and parameters and call its
`detectMarkers` method instead; in `detect_markers` the detector is built
once outside the per-frame loop. The class is available since 4.7, so this
keeps working on older OpenCV.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
masterhas been red since 24 July; the twotests/test_fiducial.pyfailures are not caused by any recent code change.pyproject.tomlpins nothing foropencv-contrib-python, so CI now installs 5.0.0.93. OpenCV 5.0 removed the freecv2.aruco.detectMarkersfunction that had been deprecated since theArucoDetectorclass arrived in 4.7. Verified locally against 5.0.0.93:hasattr(cv2.aruco, "detectMarkers")isFalse,cv2.aruco.ArucoDetectoris present and works.Both call sites now build an
ArucoDetectorfrom the dictionary and parameters and call its method. Indetect_markersthe detector is constructed once outside the per-frame loop rather than per frame.ArucoDetectorexists from 4.7 onward, so this does not raise the minimum OpenCV version for anyone still on 4.x.Not addressed here: the failure only surfaced now because nothing was watching
master's runs. #63 makes pull requests report checks, which is the other half of this.