简体   繁体   中英

error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

the code is:

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

the error is: error: (-215:Assertion failed)._src:empty() in function 'cv:.cvtColor' . enter image description here

Use cv.VideoCapture(0) instead of cv.videoCapture(0) . Your mistake is that you lower-cased the V , which should be upper-cased.
Source: Opencv Documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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