0

I am working with RaspberryPi 3 I am trying to run This code which shows below error

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)
Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
ShAn
  • 27
  • 4
  • I think, the return of `cv2.findContours` function is a tuple with 2 values like `(a, b)`. but your code expect 3 values `(im, contours, hierarchy)`. so you need check, what you want to get. – SEUNGFWANI Dec 29 '21 at 07:42
  • Not true. It has never returned (x,y) values. – Tim Roberts Dec 29 '21 at 07:46

1 Answers1

2

This is a version change. Prior to OpenCV 4.4, findCounters did return three things. Newer versions return 2: contours and hierarchy.

https://docs.opencv.org/4.4.0/d3/dc0/group__imgproc__shape.html#gadf1ad6a0b82947fa1fe3c3d497f260e0

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30