-
Notifications
You must be signed in to change notification settings - Fork 12
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
Error on ContourAreas #3
Comments
Is the accuracy level low, so is there any method to improve? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
While initially playing your code i was running into this error:
`
File "C:/Users/thinkpad/Desktop/read_serial.py", line 56, in
if cv2.contourArea(c) < 300:
error: OpenCV(4.0.1-dev) C:\Users\thinkpad\Documents\openCV4Win\opencv-master\opencv\modules\imgproc\src\shapedescr.cpp:274: error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function 'cv::contourArea'`
I fixed it by adding one variable in this line:
#cnts = cv2.findContours(dilate.copy(), cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE) cnts,hierarchy = cv2.findContours(edged.copy(), cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
It seens related to how different versions of OpenCv need different numbers of parameters for findContours.
I would have thought that the next line would cover for that, but apparently not:
cnts = cnts[0] if imutils.is_cv2() else cnts[1]
Anyway, I got it working, and I actually post this issue because I didn't find another way to thank you and send my greetings :)
Cheers!
The text was updated successfully, but these errors were encountered: