Raspberry Pi Camera Video Capture
R2026bRaspberry Pi Camera Video Capture block
To add a block to a model, double-click the canvas and start typing the block name. Then, select the block from the list.
Libraries:
Raspberry Pi Blockset /
Audio and Video
Description
The Raspberry Pi Camera Video Capture block captures video frames from a camera serial interface (CSI) on Raspberry Pi® hardware and outputs the image data as separate color panes. Use this block to capture live camera data within your Simulink® model for vision and image processing workflows on Raspberry Pi hardware.
Tune the camera output for your application using the image and device controls such as brightness, contrast, saturation, sharpness, exposure mode and compensation, white balance mode, metering mode, rotation, and region of interest (ROI).
During simulation, the block outputs a moving test-pattern image to support model development without hardware. When you run the model on Raspberry Pi, the block captures live video frames from the connected CSI camera module.
Note
To generate C/C++ code for this block, you must have an Embedded Coder® license.
Examples
This example shows how to capture live video from a Raspberry Pi CSI‑connected camera module using thee Raspberry Pi Camera Video Capture block and display the video frames in Simulink.
Create a new Simulink model and add the Raspberry Pi Camera Video Capture block from the Raspberry Pi Blockset > Audio and Video library.
Open the block parameter dialog box. Set Image
size to 640x480 and Pixel
format to RGB.
Set Sample
time to 0.1 to capture frames at 10 frames per second
(fps).
Add three Display (Simulink) blocks to the model. Connect the R, G, and B output ports of the Raspberry Pi Camera Video Capture block to the three Display blocks, respectively.

On the Hardware tab of the model, set the hardware board to your target device and configure the device address. In the Mode section, select Connected IO and then click Run with IO. Observe the live camera feed.
This example shows how to adjust image properties such as brightness and exposure for a Raspberry Pi CSI camera using the Raspberry Pi Camera Video Capture block.
Create a new Simulink model and add the Raspberry Pi Camera Video Capture block from the Raspberry Pi Blockset > Audio and Video library.
Open the block parameter dialog box. Set Image
size to 640x480 and Pixel
format to RGB.
Add three Display (Simulink) blocks to the model. Connect the R, G, and B output ports of the Raspberry Pi Camera Video Capture block to the three Display blocks, respectively.

Open the Advanced tab of the block parameters. In the
Device properties section, set Exposure mode to Normal and adjust Exposure mode
compensation to 0.7 to brighten the image.
Set AWB
mode to Daylight to optimize white balance for
outdoor lighting conditions.
On the Hardware tab of the model, in the Mode section, select Connected IO and then click Run with IO. Observe the live camera feed. While the model runs, adjust the Brightness, Contrast, Saturation, and Sharpness sliders in the block dialog box to observe changes in real time.
This example shows how to use the Flip image along horizontal axis and Flip image along vertical axis parameters to mirror an image horizontally and vertically by observing how pixel positions change from input to output. The following example uses a simplified 2x2 image where, each letter represents a pixel position.
This diagram shows how the block flips the input image along the vertical axis. The image pixels in each row swap positions from left to right, while row positions remain unchanged.

This diagram shows how the block flips the input image along the horizontal axis. The image rows swap positions from top to bottom, while column positions remain unchanged.

Extended Examples
Configure Image and Device Properties of Raspberry Pi V4L2 Video Capture Block to Detect Objects
Configure the image and device properties of the V4L2 Video Capture block from Raspberry Pi® Blockset and observe the output in the SDL Video Display block. This example also shows how to tune the image properties of the V4L2 Video Capture block to detect objects in a noisy and distorted real-time video.
Ports
Output
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:0.
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:0.
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:0.
Data Types: uint8
Parameters
Basic
Specify index of the CSI camera module connected to the Raspberry Pi hardware. Use this parameter when multiple camera modules are available.
Select the output resolution for captured video frames. Use a predefined
resolution for compatibility across camera modules. Select
Custom to define an image resolution size not listed in
the drop-down.
Specify the output resolution as a two‑element vector [width height]. Use this parameter when predefined resolutions do not meet application requirements.
Dependencies
To enable this parameter, set Image size to
Custom.
Select the color format for output data.
RGB— Outputs red, green, and blue components.YCbCr 4:2:0— Outputs luminance and chrominance components.
The selected format determines the available output ports.
Specify the time interval, in seconds, at which the block captures video frames. Lower values increase the frame capture rate.
Select the parameter to flip the image along its vertical reference. For more information, see Flip image vertically and horizontally.
Select the parameter to flip the image along its horizontal reference. For more information, see Flip image vertically and horizontally.
Advanced
Select how the camera controls exposure during image capture. Use this parameter to automatically adjust exposure dynamically based on scene lighting.
Normal— This mode balances exposure for general purpose scenes.Sport— This mode works best for scenes with shorter exposure times to reduce motion blur.
Specify an offset that increases or decrease the exposure relative to the selected exposure mode.
Select how the camera evaluates scene brightness for exposure. The mode you select determines which regions of the image contribute most to exposure calculation.
Adjust the brightness of the captured image. Larger values increase overall image brightness while smaller values reduce it.
Adjust the intensity of colors in the captured image. Lower values reduce color intensity and higher values increase it.
Adjust the contrast of the captured image by modifying the difference between light and dark regions.
Adjust the sharpness of edges and fine details in the captured image.
Rotate the captured image by the specified angle.
Select from the different white balancing modes to allow the camera to compensate for lighting conditions.
Extended Capabilities
To generate C/C++ code for this block, you must have an Embedded Coder license. For more information on selecting the right product stack according to your development goals, see Product Stack for Raspberry Pi Blockset.
Version History
Introduced in R2026b
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
