【发布时间】:2022-01-27 15:38:25
【问题描述】:
我正在使用 RaspberryPi 3 我正在尝试运行This 代码 显示以下错误
Waiting for video to adjust... Done.
Waiting for motion.
Waiting for video to adjust... Done.
Waiting for motion.
Traceback (most recent call last):
File "/home/pi/Tracking-Turret/turret.py", line 418, in <module> t.motion_detection(show_video=True)
File "/home/pi/Tracking-Turret/turret.py", line 273, in motion_detection VideoUtils.find_motion(self.__move_axis, show_video=show_video)
File "/home/pi/Tracking-Turret/turret.py", line 134, in find_motion c = VideoUtils.get_best_contour(thresh.copy(), 5000)
File "/home/pi/Tracking-Turret/turret.py", line 158, in get_best_contour im, contours, hierarchy = cv2.findContours(imgmask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
ValueError: not enough values to unpack (expected 3, got 2)
【问题讨论】:
-
我认为,
cv2.findContours函数的返回是一个具有 2 个值的元组,例如(a, b)。但您的代码需要 3 个值(im, contours, hierarchy)。所以你需要检查一下,你想得到什么。 -
不正确。它从未返回 (x,y) 值。
标签: python opencv opencv-contour motion-detection