Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

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

数カ月前に作ったArUcoアプリを再稼働させたところ

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

などというエラーが。
何もしてないのに壊れた。

実際のところ

何のことはなく、別のプロジェクトでOpenCVをアップデートした事が原因でした。
4.7.X系から命令形が変わったそうです。

なので

aruco = cv2.aruco
dictionary = aruco.getPredefinedDictionary(aruco.DICT_4X4_50)

stdin = sys.stdin.buffer.read()
array = np.frombuffer(stdin,dtype="uint8")
img_src = cv2.imdecode(array, 1)

corners, ids, rejectedImgPoints = aruco.detectMarkers( img_src, dictionary )

であったものが