Reputation: 31
I am trying to get through an OpenCV tutorial and I am using the provided source code. I run into this error:
File "C:\xxx\xxxxxxx\Desktop\basic-motion-detection\motion_detector.py", line 61, in cv2.CHAIN_APPROX_SIMPLE) ValueError: too many values to unpack.
Here is the code:
# on thresholded image
thresh = cv2.dilate(thresh, None, iterations=3)
(cnts, _) = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)`
Upvotes: 1
Views: 6324
Reputation: 594
The problem is that you are using cv2 version 3, and not version 2, the code is for version 2. To Solve your problem only change this line
(cnts, _) = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
for this:
(_, cnts, _) = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
Upvotes: 3