-1

While finding contours I am getting a value error as "too many values to unpack"

Traceback (most recent call last):
  File "C:/Python27/check5.py", line 8, in <module>
    contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
ValueError: too many values to unpack

Any idea as to why this is happening?

Abhijeetk431
  • 847
  • 1
  • 8
  • 18
  • Please show us some code – Abhijeetk431 Nov 24 '17 at 04:57
  • http://answers.opencv.org/question/32248/open-cv-30-findcontours-return-too-many-value-to-unpack/ – wwii Nov 24 '17 at 05:35
  • 1
    [From the docs](https://docs.opencv.org/trunk/d9/d8b/tutorial_py_contours_hierarchy.html) - `... in the output, we got three arrays, first is the image, second is our contours, and one more output which we named as hierarchy ...` – wwii Nov 24 '17 at 05:36
  • 1
    Possible duplicate of [too many values to unpack calling cv2.findContours](https://stackoverflow.com/questions/43960257/too-many-values-to-unpack-calling-cv2-findcontours) – Dan Mašek Nov 24 '17 at 13:15

1 Answers1

0

The function 'cv2.findContours' returns 3 values. Change your code.

_, contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)