Skip to content

Fix ArUco detection under OpenCV 5 - #64

Merged
jankoslavic merged 1 commit into
masterfrom
fix/opencv5-aruco-detector
Aug 10, 2026
Merged

Fix ArUco detection under OpenCV 5#64
jankoslavic merged 1 commit into
masterfrom
fix/opencv5-aruco-detector

Conversation

@jankoslavic

Copy link
Copy Markdown
Contributor

master has been red since 24 July; the two tests/test_fiducial.py failures are not caused by any recent code change.

AttributeError: module 'cv2.aruco' has no attribute 'detectMarkers'
pyidi/fiducial.py:136
FAILED tests/test_fiducial.py::test_compensation
FAILED tests/test_fiducial.py::test_revert_frames_shape
2 failed, 20 passed

pyproject.toml pins nothing for opencv-contrib-python, so CI now installs 5.0.0.93. OpenCV 5.0 removed the free cv2.aruco.detectMarkers function that had been deprecated since the ArucoDetector class arrived in 4.7. Verified locally against 5.0.0.93: hasattr(cv2.aruco, "detectMarkers") is False, cv2.aruco.ArucoDetector is present and works.

Both call sites now build an ArucoDetector from the dictionary and parameters and call its method. In detect_markers the detector is constructed once outside the per-frame loop rather than per frame. ArucoDetector exists 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.

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.
@jankoslavic
jankoslavic merged commit 7f867e3 into master Aug 10, 2026
3 checks passed
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.

1 participant