In [1]:
# standard setup
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import cv2

# useful helper function
from helpers import imshow
In [2]:
# load and display an image
img = cv2.imread('coins.jpg')
imshow(img)
In [10]:
# capture a frame from the camera
camera = cv2.VideoCapture(0)
ret, frame = camera.read()
imshow(frame)
camera.release()
In [9]:
# bonus: capture and display multiple frames from the camera
camera = cv2.VideoCapture(0)
while True:
    # Capture frame-by-frame
    ret, frame = camera.read()
    cv2.imshow('camera', frame)
    if cv2.waitKey(5) == 27:
        break
cv2.destroyAllWindows()
camera.release()