AttributeError: module 'cv2.aruco' has no attribute 'detectMarkers' 怎么解决
时间: 2023-11-28 09:46:02 浏览: 426
Python在Geany中调用matplotlib绘图时出现attributeerror错误
出现“AttributeError: module 'cv2.aruco' has no attribute 'detectMarkers'”错误的原因是cv2.aruco模块中没有detectMarkers方法。解决方法是使用cv2.aruco.detectMarkers()方法来代替detectMarkers()方法。具体操作如下:
```python
import cv2
import cv2.aruco as aruco
# 读取图像
img = cv2.imread('test.jpg')
# 定义字典
aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250)
# 定义参数
parameters = aruco.DetectorParameters_create()
# 检测标记
corners, ids, rejectedImgPoints = aruco.detectMarkers(img, aruco_dict, parameters=parameters)
# 显示标记
aruco.drawDetectedMarkers(img, corners, ids)
# 显示图像
cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
```
阅读全文