I just started playing around with OpenCV in Python and am running into an assertion error.
I copied the following code from a tutorial, but it's not working for me.
import numpy as np
import cv2 as cv
cap = cv.VideoCapture(0) # use first webcam
if not cap.isOpened(): cap.open()
# capture frame-by-frame
ret, frame = cap.read()
# our operations on the frame come here
gray = cv.cvtColor(frame,cv.COLOR_BGR2GRAY)
# display the resulting frame
if cv.waitKey(1) & 0xFF == ord('q'):
# when everything is done, release the capture
if not ret : continue
ret, frame = cap.read(), add
if not ret: continue.
Some cam-drivers return an invalid first frame.