Error using cv2.findContours(), with python

Look at this example.

cv2.findContours(...)

only returns two objects, you're trying to unpack it into three.

change that line to this:

contours, hierarchy =   cv2.findContours(thresh.copy(),cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE)

and it should work.


In version 4.1.2-dev it returns only two values. You have to unpack it with two values and then use cv2.drawContours() to see them. This is the link to the documentation: https://docs.opencv.org/master/d4/d73/tutorial_py_contours_begin.html


The tutorial you have linked is for OpenCV version 3. cv2.findContours does return 3 objects in that version.

So either update opencv or use the solution by @will .