I can't figure out how to generate a charuco board using opencv 4.7. Functions have changed a lot and from what I understand it should now be called like this:
dictionary = aruco.Dictionary(aruco.DICT_4X4_50, 4)
board = aruco.CharucoBoard((chkbrd_width, chkbrd_height), 6, 4, dictionary)
image = board.generateImage((1000, 1000), None, 10, 1)
But I keep receiving errors such as this on:
cv2.error: OpenCV(4.7.0) /io/opencv/modules/objdetect/src/aruco/aruco_dictionary.cpp:198: error: (-215:Assertion failed) byteList.total() > 0 && byteList.total() >= (unsigned int)markerSize * markerSize / 8 && byteList.total() <= (unsigned int)markerSize * markerSize / 8 + 1 in function 'getBitsFromByteList'
If I check the dictionary using dictionary.bytesList
, I receive the following output:
array([[0.],
[0.],
[0.],
[0.]])
This is all very frustrating, the charuco module was working quite well before so I'm not sure what the rational for changing it was. Thanks.
Following Christoph's comment, I fixed the code with:
aruco_dict = aruco.getPredefinedDictionary(aruco.DICT_4X4_50)
board = aruco.CharucoBoard((11, 7), 20, 15, aruco_dict)
board_image = board.generateImage((1000, 1000), None, 0, 1)
cv2.imshow('charuco', board_image)
cv2.waitKey(0)