AttributeError: module ‘cv2.aruco‘ has no attribute ‘GridBoard_create‘报错解决

AttributeError: module 'cv2.aruco' has no attribute 'GridBoard_create'报错解决

问题描述

使用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版本之后有一些变化,改变接口函数即可,无需降低版本等操作。

解决

改变函数即可,不需变化版本:

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(...)

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值