Ask Your Question

Revision history [back]

Assertion Error in Video Capturing ?

I've just started with openCV and trying to capture frames from webcam. But when I run the code the script catures the first frame and then Execption occurs.

import cv2, time

a = 1

while True:
    a = a + 1
    video = cv2.VideoCapture(0, cv2.CAP_DSHOW)
    check, frame = video.read()
    print(frame)
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) #This is the Erroneous line 
    cv2.imshow("Capture", gray)
    key = cv2.waitKey(1)

    if key == ord("q"):
        break
print(a)
video.release()
cv2.destroyAllWindows()

cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

click to hide/show revision 2
retagged

updated 2020-03-15 05:41:58 -0600

berak gravatar image

Assertion Error in Video Capturing ?

I've just started with openCV and trying to capture frames from webcam. But when I run the code the script catures the first frame and then Execption occurs.

import cv2, time

a = 1

while True:
    a = a + 1
    video = cv2.VideoCapture(0, cv2.CAP_DSHOW)
    check, frame = video.read()
    print(frame)
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) #This is the Erroneous line 
    cv2.imshow("Capture", gray)
    key = cv2.waitKey(1)

    if key == ord("q"):
        break
print(a)
video.release()
cv2.destroyAllWindows()

cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

click to hide/show revision 3
retagged

updated 2020-03-15 05:42:07 -0600

berak gravatar image

Assertion Error in Video Capturing ?

I've just started with openCV and trying to capture frames from webcam. But when I run the code the script catures the first frame and then Execption occurs.

import cv2, time

a = 1

while True:
    a = a + 1
    video = cv2.VideoCapture(0, cv2.CAP_DSHOW)
    check, frame = video.read()
    print(frame)
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) #This is the Erroneous line 
    cv2.imshow("Capture", gray)
    key = cv2.waitKey(1)

    if key == ord("q"):
        break
print(a)
video.release()
cv2.destroyAllWindows()

cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

Assertion Error in Video Capturing ?

I've just started with openCV and trying to capture frames from webcam. But when I run the code the script catures the first frame and then Execption occurs.

import cv2, time

a = 1

while True:
    a = a + 1
    video = cv2.VideoCapture(0, cv2.CAP_DSHOW)
    check, frame = video.read()
    print(frame)
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) #This is the Erroneous line 
    cv2.imshow("Capture", gray)
    key = cv2.waitKey(1)

    if key == ord("q"):
        break
print(a)
video.release()
cv2.destroyAllWindows()

cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'