Skip to content Skip to sidebar Skip to footer

Valueerror: Too Many Values To Unpack Python 2.7

So I am trying to compile the following code but it's showing me the error on cv2.findContours. Though, I am using Python 2.7 version. Any reason as to why the error: too many valu

Solution 1:

The issue is in the line -

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

cv2.findContours() returns 3 values , not just 2 , hence the too many values to unpack error , do -

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

cv2.findContours() returns the image , contours and hierarchy , in that order.

Post a Comment for "Valueerror: Too Many Values To Unpack Python 2.7"