Capturing Video From a Camera

The video stream class to use is based on the target you’re running on as well as the type of camera. Use this table to determine which class to use.

Target

USB Webcam

CSI (Ribbon) or Built-in Camera

Mac

WebcamVideoStream

WebcamVideoStream

Windows

WebcamVideoStream

WebcamVideoStream

Raspberry Pi

WebcamVideoStream

WebcamVideoStream

NVIDIA Jetson

WebcamVideoStream

JetsonVideoStream

Other devices

WebcamVideoStream

GStreamerVideoStream

Additionally, the following are supported across all targets:

Head to the Supported Devices page to see the full list of supported boards and cameras.

General Usage

All the video stream classes follow the same operation. Using WebcamVideoStream, the video stream can be started in the following way:

with edgeiq.WebcamVideoStream(cam=0) as video_stream:

The cam parameter is the camera index of the webcam to use, where 0 is often the default camera. The most recent frame can be read by using the read() function in the code block:

frame = video_stream.read()

Note that frames that become outdated are dropped to enable real-time analysis. The camera connection is automatically cleaned up upon exiting the code block.