Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function 'contourArea'

Tags:

python

opencv

I am trying to run the website code to create the image.

When I run the code it gives me an error:

cv2.error: OpenCV(4.1.0) 
/Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/shapedescr.cpp:274: 
error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) 
in function 'contourArea'

I am not sure about the reason behind it.

like image 566
qing zhang Avatar asked Jan 27 '23 03:01

qing zhang


1 Answers

The repo is clearly written for OpenCV 3.x. But, you are running on OpenCV 4.1. Repo code takes find_contour's second return value for contours( find_contours(...)[1] ). You should change 1 to 0.

like image 162
Sıddık Açıl Avatar answered Jan 31 '23 22:01

Sıddık Açıl