繁体   English   中英

错误:(-215:断言失败)npoints > 0 在 function 'cv::drawContours'

[英]error: (-215:Assertion failed) npoints > 0 in function 'cv::drawContours'

当我运行此代码时,底部出现错误。

for i in cnts:
    perimeter = cv2.arcLength(i, True)
    approx = cv2.approxPolyDP(i, 0.02*perimeter, True)
    if (len(approx) == 4):
        contour_with_license_plate = approx
        x, y, w, h = cv2.boundingRect(i)
        crp_img = image [y:y + h, x:x + w]
        cv2.imwrite(str(name) + '.jpg', crp_img)
        name += 1
        break

cv2.drawContours(image, [NumberPlateCount], 0 , (0, 255, 0), 3)

Traceback (most recent call last):
  File "c:\Users\xxx\xxx\xxx\xxx\xxx\xxx.py", line 54, in <module>
    cv2.drawContours(image, [NumberPlateCount], 0 , (0, 255, 0), 3)
cv2.error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-oduouqig\opencv\modules\imgproc\src\drawing.cpp:2501: error: (-215:Assertion failed) npoints > 0 in function 'cv::drawContours'

暂无
暂无

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

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