openCV function '.read()' return (False, None)
.
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
#frame = np.asarray(frame, dtype=np.uint8)
frame = frame.astype('uint8')
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
Error as below :
File "<ipython-input-18-f3066c3e32f2>", line 9, in <module>
frame = frame.astype('uint8')
AttributeError: 'NoneType' object has no attribute 'astype'
add a comment