我正在尝试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
函数显示此错误。
Traceback (most recent call last):
File "F:\Python programs\python ocv\gesture detect.py", line 37, in
<module> defects = cv2.convexityDefects(cnt,hull) AttributeError:
'module' object has no attribute 'convexityDefects'
我安装了最新版本的numpy,scipy和cv2。如果我只注释掉这段代码就可以了。