Ask Your Question
0

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

1 answer

Sort by ยป oldest newest most voted
4

answered 2014-04-24 06:24:49 -0500

berak gravatar image

updated 2014-04-24 06:27:39 -0500

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)

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

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

Seen: 7,141 times

Last updated: Apr 24 '14