ShAn
ShAn

Reputation: 27

usage of findContours causes ValueError: not enough values to unpack (expected 3, got 2)

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)

Upvotes: 0

Views: 148

Answers (1)

Tim Roberts
Tim Roberts

Reputation: 54812

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

Upvotes: 2

Related Questions