'''
Newb Code Snippets:
71-Display live webcam

From this stackoverflow post:
https://stackoverflow.com/questions/604749/
how-do-i-access-my-webcam-in-python

pip install opencv-python
'''
import cv2

cv2.namedWindow("preview")
vc = cv2.VideoCapture(0)

if vc.isOpened():
    rval, frame = vc.read()
else:
    rval = False
    print("No camera found.")

while rval:
    cv2.imshow("preview", frame)
    rval, frame = vc.read()
    key = cv2.waitKey(20)
    if key == 27: # exit on ESC
        break
cv2.destroyWindow("preview")
