Main Content

V4L2 Video Capture

Capture video from USB camera using V4L2 framework

  • Library:
  • Simulink Support Package for Raspberry Pi Hardware / Audio and Video

  • Raspberry Pi V4L2 Video Capture block icon

Description

The V4L2 Video Capture block enables you to capture live video from a USB video camera using the Video for Linux Two API (V4L2) driver framework. During simulation, the block outputs a moving colorbar image.

The debian Linux® image on Raspberry Pi™ hardware supports video capture from USB cameras compliant with the USB video class (UVC) specification. In addition to being a UVC compliant camera, the camera itself should also support data acquisition in the YUYV mode.

The following cameras have been tested with the V4L2 Video Capture block but is not limited to:

  • Logitech QuickCam Pro 9000

  • Logitech QuickCam Pro 3000

  • Logitech Webcam C600

  • Logitech HD Webcam C310

The V4L2 Video Capture block also supports the Raspberry Pi camera board.

Ports

Output

expand all

The block outputs the red component of each pixel.

Dependencies

To enable this port, set Pixel format to RGB.

Data Types: uint8

The block outputs the green component of each pixel.

Dependencies

To enable this port, set Pixel format to RGB.

Data Types: uint8

The block outputs the blue component of each pixel.

Dependencies

To enable this port, set Pixel format to RGB.

Data Types: uint8

The block outputs the luma component of each pixel.

Dependencies

To enable this port, set Pixel format to YCbCr 4:2:2.

Data Types: uint8

The block outputs the blue difference component of each pixel.

Dependencies

To enable this port, set Pixel format to YCbCr 4:2:2.

Data Types: uint8

The block outputs the red difference component of each pixel.

Dependencies

To enable this port, set Pixel format to YCbCr 4:2:2.

Data Types: uint8

Parameters

expand all

Basic

Enter the path and name of the video device. The Linux kernel creates a video device file when you connect a supported USB video camera to the target hardware. By default, the Linux kernel supports all UVC devices.

To find the name of your video device, connect the hardware to your Raspberry Pi board and follow any one of these approaches:

  • Open the Raspberry Pi Resource Monitor App. The Device ID is populated in the Peripherals section of the app.

  • Open a command line session with the Raspberry Pi hardware. Execute this command: ls -al /dev/video*.

Select the display resolution of the image in pixels.

Enter the width in pixels and the height in lines of the image.

Dependencies

To enable this parameter, set Image size to custom.

Set the format of the video device to either 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.

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

Select the parameter to flip the image along its horizontal reference axis.

Select the parameter to flip the image along its vertical reference axis.

Advanced

Image properties

Adjust the amount of light in the image.

Adjust the amount of color in the image.

Adjust the difference between the darkest and brightest areas in the image.

Adjust the sharpness to accentuate edges in an image.

Device properties

Not all cameras support the device properties.

Adjust the viewing angle of the camera in the horizontal plane.

Adjust the viewing angle of the camera in the vertical plane.

Zoom-in or zoom-out of the camera.

Select the parameter to manually adjust the camera focus.

Adjust the focus of the camera to enhance the image clarity.

Dependencies

To enable this parameter, select Enable Manual Focus.

Version History

Introduced in R2013a