添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32F || depth ==CV_32S
最新推荐文章于 2023-03-15 17:56:56 发布
最新推荐文章于 2023-03-15 17:56:56 发布

【解决】error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function ‘cv::contourArea’

In OpenCV 3.4:

    image, contours, hierarchy=  cv2.findContours(image, mode, method[, contours[, hierarchy[, offset]]]) 

In OpenCV 4.0:

contours, hierarchy= findContours(image, mode, method[, contours[, hierarchy[, offset]]]) 
在执行以上代码时,出现以下错误:
error: OpenCV(4.5.2) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-k1ohfcms\opencv\modules\imgproc\src\shapedescr.cpp:874: error: (-215:Assertion failed) npoints >= 0 && (dep
                                    昨天在使用OpenCV-Python时报错:OpenCV Assertion failed: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S),经过一番搜索,在stackoverflow上找到了答案,主要是版本问题,错误代码如下:
contours = contours[0...
                                    提示的错误是 Error: Assertion failed (((0x28442211 >> ((traits::Depth<_Tp>::value) & ((1 << 3) - 1))*4) & 15) ==在使用cv::Mat格式的数据之间进行赋值时产生的。解决错误的方法是使用。将Mat类型的数据进行统一的转换,此处我转换成了float格式(
在调用cv2.minAreaRect()时候,出现了如下错误:
cv2.error: OpenCV(4.1.1) C:\projects\opencv-python\opencv\modules\imgproc\src\convhull.cpp:137: error:(-215:Assertion failed) total >= 0 &am...
thresh = cv2.threshold(diff,0,255,cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1]
cnts = cv2.findContours(thresh.copy(),cv2.RETR_EXTERNAL,cv2.CHAIN_APP...
 (x, y, w, h) = cv2.boundingRect(contour)
cv2.error: OpenCV(4.1.1) /io/opencv/modules/imgproc/src/shapedescr.cpp:743: error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F...
                                    OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\imgproc\src\shapedescr.cpp:743: error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function 'cv::...
                                    【解决】error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32F || depth ==CV_32S
                                    今天遇到的问题
报错:error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function ‘pointSetBoundingRect’
contours = contours[0] if imutils.is_cv2() else contours[1]
(x, y, w, h) = cv2.boundingRect(cnt)
报错指向的是第二行
 > composer require --dev sixlive/json-schema-assertions
如果要使用外部架构$ref: 'bar.json ,例如$ref: 'bar.json ,则必须通过文件路径或使用配置路径解析来引用架构。 
 ├── schemas
│   ├── bar.json
│   └── foo.json
您可以使用AssertsJsonSchema特征或手动构造模式声明。 
 use sixlive\ JsonSchemaAssertions \ Concerns \ AssertJsonSchema ;
class ExampleTest extends TestCase
    use Asserts
Traceback (most recent call last):
  File "***.py", line 47, in <module>
    (x, y, w, h) = cv2.boundingRect(contour)
cv2.error: OpenCV(4.0.0) /Users/travis/build/skvark/opencv-python/open...