python - opencv python没有足够的值来解压
问题描述
我正在尝试做一个手势控制的智能镜子。但是当我尝试运行时test.py
,相机打开了一秒钟,然后突然关闭。这是我得到的输出。
DEBUG:asyncio:Using selector: SelectSelector
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "test.py", line 85, in ManageMotion
gesture = motion.GetGesture()
File "C:\Users\admin\Desktop\SmartMirror\Motion\motion.py", line 192, in GetGesture
self.TryToTrackHand()
File "C:\Users\admin\Desktop\SmartMirror\Motion\motion.py", line 116, in TryToTrackHand
foundPalm = search_hand.SearchPalmFromMask(search_hand_mask)
File "C:\Users\admin\Desktop\SmartMirror\Motion\gesture.py", line 134, in SearchPalmFromMask
if self.InitFromMask(search_hand_mask):
File "C:\Users\admin\Desktop\SmartMirror\Motion\gesture.py", line 101, in InitFromMask
(_, contours, _) = cv2.findContours(search_hand_mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
ValueError: not enough values to unpack (expected 3, got 2)
[ WARN:0] global D:\Build\OpenCV\opencv-4.1.2\modules\videoio\src\cap_msmf.cpp (674) SourceReaderCB::~SourceReaderCB terminating async callback
解决方案
cv2.findContours()
函数将返回 2 个值,而不是 3 个。
将它们读作:
contours, _ = cv2.findContours(...)
推荐阅读
- c++ - C++:在 Application.cpp 中抛出未解析的外部符号(解决方案在问题的末尾供未来的读者使用)
- javascript - 如何在没有错误的情况下计算这个近似值
- php - 将4级邻接数据库转为数组再转为JSON格式
- reactjs - 测试和持续集成
- java - Java GPIO 解构器
- javascript - Javascript中的八进制转换问题
- swift - NSTrackingArea 并不总是更新游标
- c++ - 为什么即使代码中没有输入,控制台也会要求输入?
- delphi - 如何为 cxGrid 中的列设置默认值?
- firebase - Firestore 不侦听查询 (Flutter)