问题描述
使用Opencv的Python版本,运行:
ARUCO_PARAMETERS = aruco.DetectorParameters_create()
ARUCO_DICT = aruco.Dictionary_get(aruco.DICT_ARUCO_ORIGINAL)
corners, ids, rejectedImgPoints = aruco.detectMarkers(frame, ARUCO_DICT, parameters=ARUCO_PARAMETERS)
报错:
AttributeError: module 'cv2.aruco' has no attribute 'DetectorParameters_create'
原因
网上查了很多,说是把opencv版本降低。其实这就是版本的问题,pip show opencv-python
发现:
Name: opencv-python
Version: 4.7.0.68
Summary: Wrapper package for OpenCV python bindings.
Home-page: https://github.com/opencv/opencv-python
Author:
Author-email:
License: MIT
Location: /home/anaconda3/envs/xxx/lib/python3.9/site-packages
Requires: numpy, numpy, numpy
Required-by:
上述函数接口在4.7.x版本之后有一些变化,改变接口函数即可,无需降低版本等操作。
解决
改变函数即可,不需变化版本:文章来源:https://www.toymoban.com/news/detail-515914.html
from cv2 import aruco
ARUCO_PARAMETERS = aruco.DetectorParameters()
ARUCO_DICT = aruco.getPredefinedDictionary(aruco.DICT_ARUCO_ORIGINAL)
detector = aruco.ArucoDetector(ARUCO_DICT,ARUCO_PARAMETERS)
corners, ids, rejectedImgPoints = detector.detectMarkers(frame)
其中,frame为之前的imread读入,即frame = cv2.imread(...)
文章来源地址https://www.toymoban.com/news/detail-515914.html
到了这里,关于AttributeError: module ‘cv2.aruco‘ has no attribute ‘GridBoard_create‘报错解决的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!