Skip to Main Content Skip to Search
Product Documentation

From Video Device - Acquire live image data from image acquisition device

Library

Image Acquisition Toolbox

Description

The From Video Device block lets you acquire image and video data streams from image acquisition devices, such as cameras and frame grabbers, in order to bring the image data into a Simulink model. The block also lets you configure and preview the acquisition directly from Simulink.

The From Video Device block opens, initializes, configures, and controls an acquisition device. The opening, initializing, and configuring occur once, at the start of the model's execution. During the model's run time, the block buffers image data, delivering one image frame for each simulation time step.

The block has no input ports. You can configure the block to have either one output port, or three output ports corresponding to the uncompressed color bands, such as red, green, and blue, or Y, Cb, Cr. The previous figure shows both configurations.

Other Supported Features

The From Video Device block supports the use of Simulink Accelerator mode. This feature speeds up the execution of Simulink models.

The From Video Device block supports the use of model referencing. This feature lets your model include other Simulink models as modular components.

For more information on these features, see the Simulink documentation.

The From Video Device block supports the use of code generation along with the packNGo function to group required source code and dependent shared libraries. See the next section.

Code Generation

The From Video Device block supports the use of code generation. You can generate code from the block. This enables models containing the From Video Device block to run successfully in Accelerator, Rapid Accelerator, External, and Deployed modes.

Code Generation with the Simulink Coder

You can use the Image Acquisition Toolbox, Simulink Coder, and Embedded Coder™ products together to generate code (on the host end) that you can use to implement your model for a practical application. For more information on code generation, see Program Building, Interaction, and Debugging.

Shared Library Dependencies

The From Video Device block generates code with limited portability. The block uses precompiled shared libraries, such as DLLs, to support I/O for specific types of devices. The Simulink Coder software provides functions to help you set up and manage the build information for your models. One of the Build Information functions that Simulink Coder provides is packNGo. This function allows you to package model code and dependent shared libraries into a zip file for deployment. The target system does not need to have MATLAB installed but it does need to be supported by MATLAB.

The block supports use of the packNGo function. Source-specific properties for your device are honored when code is generated. The generated code compiles with both C and C++ compilers.

To set up packNGo:

set_param(gcs, 'PostCodeGenCommand', 'packNGo(buildInfo)');

In this example, gcs is the current model that you wish to build. Building the model creates a zip file with the same name as model name. You can move this zip file to another machine and the source code in the zip file can be built to create an executable which can be run independent of MATLAB and Simulink. For more information on packNGo, see packNGo.

Dialog Box

In the Source Block Parameters dialog box, the options that appear are dependent on the device you are using. The first diagram illustrates the fields that may appear if your device supports hardware triggering and Bayer Sensor Alignment as a color space option.

The second diagram illustrates the options that may appear if your device supports using either one output port or multiple output ports for the color bands (the Ports mode option). Ports mode is visible if the selected device and format settings can output color data.

The following fields appear in the Source Block Parameters dialog box. Some fields may not appear, as they are device dependent. If your selected device does not support a feature, it may not appear in the dialog box.

Device

The image acquisition device to which you want to connect. The items in the list vary, depending on which devices you have connected to your system. All video capture devices supported by the Image Acquisition Toolbox software are supported by the block.

Video format

Shows the video formats supported by the selected device. This list varies with each device. If your device supports the use of camera files, From camera file will be one of the choices in the list.

Camera file

This option only appears if you select a device that supports camera files. You can select From camera file from the Video format field, and enter the path and file name, or use the Browse button to locate the file.

Video source

The available input sources for the specified device and format. You can use the Edit properties button to edit the source properties. That will open the Property Inspector.

Edit properties button

Edits video source device-specific properties, such as brightness and contrast. It opens the Property Inspector. The properties that are listed vary be device. Properties that can be edited are indicated by a pencil icon or a drop-down list in the table. Properties that are grayed out cannot be edited. When you close the Property Inspector, your edits are saved.

Enable hardware triggering

This option only appears if the selected device supports hardware triggering. Select the check box to enable hardware triggering. Once enabled, you can select the Trigger configuration.

Trigger configuration

This option only appears if the selected device supports hardware triggering. Check the Enable hardware triggering box to enable it. Once enabled, you can select the Trigger configuration. The configuration choices are listed by trigger source/trigger condition. For example, TTL/fallingEdge means that TTL is the trigger source and the falling edge of the signal is the condition that triggers the hardware.

ROI position

Use this field to input a row vector that specifies the region of acquisition in the video image. The format is [row, column, height, width]. The default values for row and column are 0. The default values for height and width are set to the maximum allowable value, indicated by the video format's resolution. Therefore you only need to change the values in this field if you do not want to capture the full image size.

Output color space

Use this field to select the color space for devices that support color. Possible values are rgb, grayscale, and YCbCr. The default value is rgb. If your device supports Bayer Sensor Alignment, a fourth value of bayer is also available.

Bayer sensor alignment

This field is only visible if your device supports Bayer sensor alignment. You must set the Output color space field to bayer, then it becomes activated. Use this to set the 2-by-2 sensor alignment. Possible values are grbg, gbrg, and rggb, and bggr. The default value is grbg.

Preview button

Preview the video image. It opens the Video Preview window that is part of the Image Acquisition Toolbox software. If you change something in the Source Block Parameters dialog box while the preview is running, the image will adjust accordingly. This lets you set up your image acquisition to the way you want it to be acquired by the block when you run the model.

Block sample time

Specify the sample time of the block during the simulation. This is the rate at which the block is executed during simulation. The default is 1/30.

    Note   The block sample time does not set the frame rate on the device that is used in simulation. Frame rate is determined by the video format specified (standard format or from a camera file). Some devices even list frame rate as a device-specific source property. Frame rate is not related to the Block sample time option in the dialog. Block sample time defines the rate at which the block executes during simulation time.

Ports mode

Used to specify either a single output port for all color spaces, or one port for each band (for example, R, G, B). When you select One multidimensional signal, the output signal will be combined into one line consisting of signal information for all color signals. Select Separate color signals if you want to use three ports corresponding to the uncompressed red, green, and blue color bands. Note that some devices will use YCbCr for the separate color signals.

    Note   The block acquires data in the default ReturnedColorSpace setting for the specified device and format.

Data type

The image data type when the block outputs frames. This data type indicates how image frames are output from the block to Simulink. It supports all MATLAB data types and single is the default.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS