1

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)`
3

1 Answer 1

3

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.