簡體   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