(-215:断言失败)npoints> = 0&&函数"contourArea"中的(深度== CV_32F ||深度== CV_32S)
问题描述:
我正在尝试运行创建图像的网站代码.
当我运行代码时,它给了我一个错误:
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.
答
该仓库显然是为OpenCV 3.x编写的.但是,您正在OpenCV 4.1上运行.回购代码采用find_contour的轮廓的第二个返回值(find_contours(...)[1]
).您应该将1更改为0.
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.