繁体   English   中英

如何修复 Opencv arcLength function 错误:(-215:断言失败)

[英]How to fix Opencv arcLength function error: (-215:Assertion failed)

以下代码给了我以下错误:

contours = cv2.findContours(horizontal_lines_canvas, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
contours = contours[1]
contours = sorted(contours, key=lambda c: cv2.arcLength(c, True), reverse=True)[:2]

错误:

cv2.error:OpenCV(4.0.0)/Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/shapeescr.cpp:237:错误:(-215:断言失败)计数> = 0 && (depth == CV_32F || depth == CV_32S) 在 function 'arcLength'

  • OpenCV 版本: 4.0.0
  • Python 版本: 3.7

为什么这样? 一切似乎都是正确的

谢谢你,汉斯希尔斯。

替换为:

contours, hierarchy = cv2.findContours(..

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM