gpt4 book ai didi

python - 手势检测

转载 作者:行者123 更新时间:2023-12-02 17:05:30 25 4
gpt4 key购买 nike

当我运行这个:

contours,_,hierarchy = cv2.findContours(thresh.copy(),cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)

我收到此错误:
ValueError: not enough values to unpack (expected 3, got 2)

我也尝试过:
_, contours,hierarchy = cv2.findContours(thresh.copy(),cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)

和:
contours,hierarchy,_ = cv2.findContours(thresh.copy(),cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)

并得到此错误:
Traceback (most recent call last):
File "C:/Users/HASHMATI/AppData/Local/Programs/Python/Python37-32/new2hand.py", line 152, in <module>
gestureRecognition(frame,roi_rect,frame[y:y+h, x:x+w])
File "C:/Users/HASHMATI/AppData/Local/Programs/Python/Python37-32/new2hand.py", line 99, in gestureRecognition
detectGesture(src,roi_rect,img_dilated)
File "C:/Users/HASHMATI/AppData/Local/Programs/Python/Python37-32/new2hand.py", line 21, in detectGesture
contours,_,hierarchy = cv2.findContours(thresh.copy(),cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
ValueError: not enough values to unpack (expected 3, got 2)

最佳答案

这是OpenCV 3.x和4.x之间的区别。在3.x中,有三个返回值,在4.x中,只有两个。正如其他人提到的那样,您仅捕获contourshierarchy:

contours, hierarchy = cv2.findContours(thresh.copy(),cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)

另外,如果您真正想要的是使用3.x,则可以降级您的OpenCV版本。

关于python - 手势检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55411176/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com