open cv 3.0, findContours return "too many value to unpack"

asked 2014-04-24 05:42:29 -0500

foulques.nera gravatar image

updated 2014-04-24 06:49:11 -0500

berak gravatar image

Switching to OpenCV 3.0.0-tp2 / Version control: 2.4.8, my previous working code using findContours() fails

ret, frame = self.cap.read()
edges = cv2.Canny(frame,100,200)
contours, hierarchy = cv2.findContours( edges, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
>>> too many values to unpack

Best regards

edit retag flag offensive close merge delete

Comments

3

yes, that seems to have changed in 3.0.

>>> import cv2

>>> help(cv2.findContours)

Help on built-in function findContours in module cv2:

findContours(...)

findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> image, contours, hierarchy


so, you probably need:

_, contours, hierarchy = cv2.findContours(...)

(one more return value)

berak gravatar imageberak ( 2014-04-24 06:24:49 -0500 )edit