Shideh
Shideh

Reputation: 117

Too many values to unpack / Needs at least 3 values - OpenCV - Python

Here's the snippet of my code:

ret,thresh = cv2.threshold(image,127,255,0)
contours,hierarchy = cv2.findContours(thresh, 1, 2)
cnt = contours[0]
M = cv2.moments(cnt)
print M

At first it gave me the error:

Too many values to unpack.

Then I changed my code to this:

_,contours,_,hierarchy = cv2.findContours(thresh, 1, 2)

There was a new error saying:

Needs at least 3 values

Anyone knows how to fix this?

Upvotes: 0

Views: 1668

Answers (1)

Shideh
Shideh

Reputation: 117

it returns: img,contours,hierarchy in opencv3.0 but only contours,hierarchy in 2.4 – berak

Upvotes: 4

Related Questions