-1

I am running the following code snippet on a test video. The code runs the starting frames without problem but at one point starts giving the following error

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

Here is the code snippet.

cap = cv2.VideoCapture('test/Pedestrian overpass.mp4')
#cap = cv2.VideoCapture('test/dark1.mp4')

if (cap.isOpened() == False):
    print("Error opening video stream / file")
    exit(0)
else:
    print("Hello")
    ret , frame0 = cap.read()
    prevFrame = cv2.cvtColor(frame0, cv2.COLOR_BGR2GRAY)

1 Answers1

0

trying this:

  ret , frame0 = cap.read()
    if not frame0 is None:
        prevFrame = cv2.cvtColor(frame0, cv2.COLOR_BGR2GRAY)    
Zhubei Federer
  • 1,274
  • 2
  • 10
  • 27