错误:(-215:断言失败)函数'cv :: cvtColor'中的!_src.empty()

时间:2019-11-01 13:50:17

标签: python visual-studio visual-studio-2019 cv2

代码为:

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()

错误是:  错误:(-215:断言失败)函数'cv :: cvtColor'中的!_src.empty() enter image description here

1 个答案:

答案 0 :(得分:1)

使用cv.VideoCapture(0)代替cv.videoCapture(0)。您的错误是您将 V 设置为小写。
来源:Opencv Documentation