V4L2 Video Capture

Capture video from USB camera using V4L2


Capture live video from a USB video camera, using the V4L2 (Video for Linux Two API) driver framework. The output is in row major format. During simulation, the model outputs a moving colorbar image.

The Ubuntu Linux image used on the target hardware supports video capture from USB cameras listed as Universal Video Class (UVC). In addition to being a UVC class camera, the camera itself must support data acquisition in YUYV mode.

The following cameras have been tested:

  • Logitech QuickCam Pro 9000

  • Logitech QuickCam Pro 3000

  • Logitech Webcam C600

  • Logitech HD Webcam C310

For a list of Logitech webcams that support UVC, see For a list of UVC cameras supported by Ubuntu, see

For Raspberry Pi™ hardware only: To capture video from the Raspberry Pi Camera Board, search Help for "Add Support for Raspberry Pi Camera Board".

For BeagleBoard hardware only: If you connect any USB camera to a USB Host port on the board, the video output contains artifacts that look like small dark scratches. This is a known hardware issue, and is independent of the Linux distribution. To work around this issue, connect the camera to the BeagleBoard's USB OTG port using a "Micro USB OTG to USB 2.0 Adapter". The USB OTG port is labelled "OTG" and is located next to the BeagleBoard's "5V" or "5VDC" connector. This issue is discussed at:


Device Configuration

Device name

Enter the path and name of the video device. This parameter value defaults to '/dev/video0'.

The Linux kernel creates a video device file when you connect a supported USB video camera to the board. By default, the Linux kernel supports all USB video class (UVC) devices.

To see the list of video device files, open a command line session with the board and enter: ls -al /dev/video*.

Image size ([width, height])

Specify the width in pixels and height in lines of the image to capture.

This parameter value defaults to [640, 480].

Pixel format

Select the video format of the video device, RGB or YCbCr 4:2:2.

RGB represents the red, green, and blue components of a pixel using an 8-bit value. RGB color space is device-dependent.

YCbCr 4:2:2 uses three channels to represent color image data for each pixel:

  • Y is the luma component (essentially a grayscale signal).

  • Cb is the blue-difference chroma component.

  • Cr is the red-difference chroma component.

The Cb and Cr components are sampled at half the sample rate of Y. See

This parameter value defaults to YCbCr 4:2:2.

Sample time

Select the sample time of the video device. This parameter value defaults to 1/10

Smaller values require the processor to complete the same number of instructions in less time, which can cause task overruns.

Was this topic helpful?