# standard setup
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import cv2
# useful helper function to show images inline
from helpers import imshow
img = cv2.imread('coins.jpg')
imshow(img)
# capture a frame from the camera
camera = cv2.VideoCapture(0)
ret, frame = camera.read()
imshow(frame)
camera.release()
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()
print('destroy')
camera.release()
print('release')
cv2.waitKey(1) # extra waitKey sometimes needed to close camera window