AttributeError: module 'cv2.aruco' has no attribute 'drawFrameAxes'

Question:

I am working with VSCode 1.68.1, Ubuntu 20.04
I am following link (https://programming.vip/docs/3d-pose-estimation-using-aruco-tag-in-python.html) to achieve pose estimation for aruco marker

But I am getting below error:
aruco.drawFrameAxes(dst1, mtx, dist, rvec[i, :, :], tvec[i, :, :],0.03)
AttributeError: module ‘cv2.aruco’ has no attribute ‘drawFrameAxes’

  • I tried using aruco.drawaxis as well, same error
  • Also tried uninstall opencv-python, uninstall opencv-contrib-python, then pip3 install opencv-python & pip3 install opencv-contrib-python, same error
Asked By: Manpreet

||

Answers:

drawFrameAxes is an independent module available in OpenCV. It isn’t found within aruco package.

The command: help(cv2.drawFrameAxes) gives you all the details you need regarding its usage and parameters.

Try the following in your code:

result_img = cv2.drawFrameAxes(dst1, mtx, dist, rvec[i, :, :], tvec[i, :, :],0.03)

Documentation Link

Answered By: Jeru Luke

Did you try compiling opencv from source? I did this out of desperation and the function seemed to work afterwards.

I was not able to get this working with the alternative contrib-opencv-python package either.

Answered By: homicidalbrainiac