Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test.py - additional output needed in cv2.findContours #1

Open
jlkittle opened this issue Jun 27, 2016 · 4 comments
Open

test.py - additional output needed in cv2.findContours #1

jlkittle opened this issue Jun 27, 2016 · 4 comments

Comments

@jlkittle
Copy link

cv2.findContours returns 3 values , not just 2 , which leads to a 'too many values to unpack'
i added 'contourImage, ' as a dummy before 'contours, '

@iandees
Copy link
Owner

iandees commented Jun 27, 2016

Huh, what version of opencv are you running? findContours() returns a 2-tuple in my version.

@jlkittle
Copy link
Author

cv2.version returns 3.1.0

@guatnutz
Copy link

if you're running opencv3+ you will need to modify the line:

contours, hierarchy = cv2.findContours(thresholdImage, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

to reflect the small syntax changes to cv2.findCountours that have been made since opencv2.x

(_,contours, hierarchy) = cv2.findContours(thresholdImage, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

also for some really strange reason, I needed to specify where my cv2.so was (all my other programs can find it with import cv2) so I also had to add this code:

import sys
sys.path.append('the path to your cv2.so file goes here')

note that the above is most likely something funky with my python / opencv - this is just a workaround for me because it imports fine in anything else, if you run into this issue with all the files you're running you need to fix your installations, it sounds like you didn't make/compile opencv correctly. the opencv website has a good installation tutorial also adrian from pyimagesearch has excellent resources on this (i personally don't like using virtualenv - I originally started learning with his virtualenv set-up and it made things a bit more difficult then they had to be, but working through the issues with getting his set-up working i ended up learning a lot more!)

iandees - thanks for the code brother!

@ashupednekar
Copy link

Sir, where can I get your video sample?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants