I want to read a camera with cv2.
This is my code:
import cv2 as cv
cv.namedWindow('mah Window', cv.WINDOW_NORMAL)
source = cv.VideoCapture(0)
while(1):
ret, frame = source.read()
if not ret:
break
if cv.waitKey(1) == ord('q'):
break
sorce.release()
cv.destroyAllWindows()
when I run this I receive:
Your session crashed. Automatically restarting.
Your session restarted after a crash. Diagnosing...
Your session crashed for an unknown reason. View runtime logs
(View runtime logs) is a link to a table with some date and time
Colab is not your own computer. Colab is a Google server.
You can't have namedWindow
or imshow
or waitKey
in Colab. The Colab server has no display attached to it.
You can't have VideoCapture
in Colab. There is no webcam attached to the Google server.