OpenCV supports receiving data from a webcam, and by default it comes with the Python shell, you also need to install numpy so that the OpenCV Python extension cv2 (called cv2 ). Since 2019, you can install both of these libraries with pip: pip install numpy pip install opencv-python
More information on using OpenCV with Python .
Example copied from showing a feed using opencv and python :
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")
John Montgomery Mar 03 '09 at 12:09 2009-03-03 12:09
source share