V4L2 Video Capture
Capture video from USB camera using V4L2
Add-On Required: This feature requires the Embedded Coder Support Package for BeagleBone Black Hardware add-on.
Description
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 Linux® image used on the target hardware supports video capture from USB cameras listed as Universal Video Class (UVC). 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
Sometimes, when you connect a USB webcam to the BeagleBone® Black hardware that was running, the BeagleBone Black hardware does not recognize the USB webcam. To verify that the BeagleBone Black hardware recognizes the USB webcam, in the Command Window, enter:
bbone = beaglebone_black; system(bbone,'ls -al /dev/videox')
If the board recognizes the USB camera, this command returns the name of the video device associated with the USB camera. Otherwise, restart the BeagleBone Black hardware. After restarting, if the BeagleBone Black hardware does not recognize the USB webcam, is possible that the webcam is not a supported device. Try using a different USB webcam.
Parameters
Device Configuration
- Device name
Enter the path and name of the video device. This parameter value defaults to
'/dev/video0'
.When you connect a supported USB video camera to the board, the Linux kernel creates a video device file. 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
orYCbCr 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 camera samples the Cb and Cr components at half the sample rate of Y. See https://en.wikipedia.org/wiki/Chroma_subsampling.
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.
Version History
Introduced in R2014b