# Use the 'pylab' system for plotting. This is IPython-specific. %pylab inline # Under 'normal' Python, you'd import the functions directly from matplotlib and numpy from matplotlib.pyplot import * import numpy as np # Use OpenCV import cv2 # Set default figure size to be a bit bigger rcParams['figure.figsize'] = (12,12) capture = cv2.VideoCapture() dir(capture) capture.open(0) capture.isOpened() grabbed, frame = capture.read() print('Frame grabbed: {0}'.format(grabbed)) # The 'shape' of the frame is a 3-tuple giving the number of rows, columns and colour components frame.shape # NB the image returned from the camera has the colour components ordered: Blue, Green and Red, just to be annoying. frame_grey = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) imshow(frame_grey, cmap=cm.gray) import cv capture.set(cv.CV_CAP_PROP_FRAME_WIDTH, 1280) capture.set(cv.CV_CAP_PROP_FRAME_HEIGHT, 720) grabbed, frame = capture.read() frame_grey = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) imshow(frame_grey, cmap=cm.gray) print('Frame grabbed: {0}'.format(grabbed)) imshow(frame) imshow(frame[:,:,(2,1,0)])