![](/img/trans.png)
[英]cv2.error: OpenCV(4.5.2) .error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
[英]error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
代碼是:
import numpy
import cv2 as cv
cap=cv.VideoCapture(0)
while True :
#ret will get non or value
ret,frame=cap.read()
#for make frames gray who did this library make RGB=>BGR
gray=cv.cvtColor(frame,cv.COLOR_BGR2GRAY)
cv.imshow('fram',gray)
#if the user click q or exit the vedio
if cv.waitKey(1)&0xFF==ord('q'):
break
cap.release()
cv.destroyAllWindows()
錯誤是: error: (-215:Assertion failed)._src:empty() in function 'cv:.cvtColor' 。 在此處輸入圖像描述
使用cv.VideoCapture(0)
而不是cv.videoCapture(0)
。 你的錯誤是你小寫了V ,它應該是大寫的。
資料來源: Opencv 文檔
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.