Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dishankjindal1/86c844747e0d4b6e140909d38fc1b218 to your computer and use it in GitHub Desktop.
Save dishankjindal1/86c844747e0d4b6e140909d38fc1b218 to your computer and use it in GitHub Desktop.
from cv2 import cv2
video = cv2.VideoCapture(0)
if not video.isOpened():
print("Cannot open camera")
exit()
while True:
ret, frame = video.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame', gray)
if cv2.waitKey(1) == ord('q'):
break
video.release()
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment