Created
December 24, 2019 08:56
-
-
Save vereperrot/d120c6e87046abc1f16f86a4183c10ce to your computer and use it in GitHub Desktop.
access webcam.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
cv2.namedWindow("preview") | |
vc = cv2.VideoCapture(0) | |
if vc.isOpened(): # try to get the first frame | |
rval, frame = vc.read() | |
else: | |
rval = False | |
while rval: | |
cv2.imshow("preview", frame) | |
rval, frame = vc.read() | |
key = cv2.waitKey(20) | |
if key == 27: # exit on ESC | |
break | |
cv2.destroyWindow("preview") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment