I'm following this tutorial on getting started with aruco markers.
I want to get the pose estimation frame axis and display it ontop of the aruco marker like so:
Here is the relevant code snippet from the tutorial:
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
detector = cv2.aruco.ArucoDetector(arucoDict, arucoParams)
(corners, ids, rejected) = detector.detectMarkers(gray)
if len(corners) > 0:
for i in range(0, len(ids)):
rvec, tvec, markerPoints = cv2.aruco.estimatePoseSingleMarkers(corners[i], 0.02, mtx, dist)
cv2.drawFrameAxes(frame, mtx, dist, rvec, tvec, 0.02)
But I get the following attributional error:
AttributeError: module 'cv2.aruco' has no attribute 'estimatePoseSingleMarkers'
My python version: 3.11.2 OpenCV version: 4.7.0
How do I get the pose and draw them in the aruco marker?
Installing an older version of opencv-contrib-python solves the issue.
pip install opencv-contrib-python==4.6.0.66
You might have to uninstall existing opencv and opencv-contrib-python before that to avoid conflicts: Python opencv Aruco "No module named 'cv2.aruco'"
So,
pip uninstall opencv-python -y
pip uninstall opencv-contrib-python -y
followed by
pip install opencv-contrib-python==4.6.0.66
should work.
You can look into the latest build for any changes: https://github.com/opencv/opencv-python