简体   繁体   English

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

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

The following code is giving me the following error:以下代码给了我以下错误:

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]

ERROR:错误:

cv2.error: OpenCV(4.0.0) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/shapedescr.cpp:237: error: (-215:Assertion failed) count >= 0 && (depth == CV_32F || depth == CV_32S) in function 'arcLength' 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 version: 4.0.0 OpenCV 版本: 4.0.0
  • Python version: 3.7 Python 版本: 3.7

Why so?为什么这样? All seems correct一切似乎都是正确的

Thank you, HansHirse.谢谢你,汉斯希尔斯。

Replaced with:替换为:

contours, hierarchy = cv2.findContours(..

暂无
暂无

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

相关问题 如何修复opencv / modules / objdetect / src / cascadedetect.cpp:1698:错误:(-215:断言失败)!empty()在函数'detectMultiScale'^中? - How to fix opencv/modules/objdetect/src/cascadedetect.cpp:1698: error: (-215:Assertion failed) !empty() in function 'detectMultiScale'^? 如何在 pycharm 中修复此错误? cv2.error: OpenCV(3.4.2) 错误: (-215:Assertion failed) - How to fix this error in pycharm? cv2.error: OpenCV(3.4.2) error: (-215:Assertion failed) OpenCV错误:(-215:断言失败)!_src.empty()在函数'cvtColor'中 - OpenCV error: (-215:Assertion failed) !_src.empty() in function 'cvtColor' OpenCV 调整大小错误(-215:断言失败) - OpenCV resize error(-215:Assertion Failed) python OpenCV(3.4.2)错误:(-215:断言失败) - python OpenCV(3.4.2) error: (-215:Assertion failed) 错误: (-215:Assertion failed) 使用 openCV 时 - error: (-215:Assertion failed) while using openCV OpenCV 错误:(-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'CvtHelper' - OpenCV Error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'CvtHelper' OpenCV 4.4.0 错误:(-215:断言失败)._img:empty() 在 function 'cv::imwrite' - OpenCV 4.4.0 error: (-215:Assertion failed) !_img.empty() in function 'cv::imwrite' OpenCV(4.2.0) 错误: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow' - OpenCV(4.2.0) error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow' 在 function 'cvtColor' 中收到 Opencv: (-215:Assertion failed)._src.empty() 中的错误 - Receiving the error in Opencv: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM