笔势控制错误:AttributeError:“module”对象没有属性“convexityDefects”

2024-06-10 06:41:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试this tutorial来进行手势识别和控制

在我把这一部分添加到代码中之前,它运行得很好:

defects = cv2.convexityDefects(cnt,hull)

mind=0
maxd=0

for i in range(defects.shape[0]):
    s,e,f,d = defects[i,0]
    start = tuple(cnt[s][0])
    end = tuple(cnt[e][0])
    far = tuple(cnt[f][0])
    dist = cv2.pointPolygonTest(cnt,centr,True)
    cv2.line(img,start,end,[0,255,0],2)
    cv2.circle(img,far,5,[0,0,255],-1)

print(i)
i=0

出于某些原因,python为convexityDefects函数显示了此错误。在

^{pr2}$

我安装了最新版本的numpy,scipy和cv2。如果我只注释掉代码的这一部分,它运行得很好。在


Tags: 代码imgthiscv2starttutorialendfar