Home > Blockchain >  cv2.aruco.CharucoBoard_create not found in OpenCV 4.7.0
cv2.aruco.CharucoBoard_create not found in OpenCV 4.7.0

Time:01-12

I have installed opencv-python-4.7.0.68 and opencv-contrib-python-4.7.0.68

The code below gives me the following error:
AttributeError: module 'cv2.aruco' has no attribute 'CharucoBoard_create'

Sample code:

import cv2

aruco_dict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_4X4_50)
board = cv2.aruco.CharucoBoard_create(11, 8, 0.015, 0.011, aruco_dict)

CodePudding user response:

This is due to a change that happened in release 4.7.0, when the Aruco code was moved from contrib to the main repository.

The constructor cv2.aruco.CharucoBoard_create has been renamed to cv2.aruco.CharucoBoard and its parameter list has changed slightly -- instead of the first two integer parameters squaresX and squaresY, you should pass in a single tuple with two values, representing the size. (Note: The documentation seems to be missing the Python constructor's signature. Bug report has been filed.)

So, your code should look like:

import cv2

aruco_dict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_4X4_50)
board = cv2.aruco.CharucoBoard((11, 8), 0.015, 0.011, aruco_dict)
  • Related