Skip to Main Content Skip to Search
Product Documentation

Saving Video Data to a File

Introduction

The best way to learn about the Image Acquisition Toolbox From Video Device block is to see an example. This section provides a step-by-step example that builds a simple model using the block in conjunction with blocks from other blockset libraries.

Step 1: Open the Image Acquisition Toolbox Library

To use the From Video Device block, you must open the Image Acquisition Toolbox block library. To open the library, start the Simulink Library Browser and select the Image Acquisition Toolbox entry from the list.

To start the Simulink Library Browser, enter

simulink

at the MATLAB prompt. (For more information about opening the library, see Opening the Block Library.)

Step 2: Open a Model or Create a New Model

To use a block, you must add it to an existing model or create a new model.

To create a new model, select File > New > Model from the Simulink Library Browser. Simulink opens an empty model window. To assign the new model a name, use the Save option.

Step 3: Drag the From Video Device Block into the Model

To use the From Video Device block in a model, click the block in the library and, holding the mouse button down, drag it into the model window. Note how the name on the block changes to reflect the device connected to your system that is associated with the block.

Drag From Video Device Block into Model Window

Step 4: Drag Other Blocks to Complete the Model

To illustrate using the block, this example creates a simple model that acquires data and then outputs the data to a file in Audio Video Interleave (AVI) format. To create this model, the example uses a block from Computer Vision System Toolbox.

Open the Computer Vision System Toolbox library. In the library window, open the Sinks subsystem. From this subsystem, click the To Multimedia File block in the library and, holding the mouse button down, drag the block into the model window.

Drag Output Block to Model Window

Step 5: Connect the Blocks

Connect the three outputs from the From Video Device block to the three corresponding inputs on the To Multimedia File block. (You can leave the Audio input on the To Multimedia File block unconnected.) One quick way to make all three connections at once is to select the From Video Device block, press and hold the Ctrl key, and then click the To Multimedia File block.

Notice that the output ports on this particular camera device are Y, Cb, Cr and the input ports on the To Multimedia File block are R, G, B. Some devices designate color band by YCbCr and some devices designate it by RGB. Both are valid and will work together.

Connect the From Video Device Block to the To Multimedia File Block

Step 6: Specify From Video Device Block Parameter Values

To check From Video Device block parameter settings, double-click the block's icon in the model window. This opens the Source Block Parameters dialog box for the From Video Device block, shown in the following figure. Use the various fields in the dialog box to determine the current values of From Video Device block parameters or change the values.

For example, using this dialog box, you can specify the device you want to use, select the video format you want to use with the device, or specify the block sample time. For more details, see the From Video Device block reference page.

You can set parameters for any of the blocks you include in your model. For example, to specify the name of the AVI file, double-click the To Multimedia File block. Make sure that you have write permission to the directory into which the block writes the AVI file.

Step 7: Run the Simulation

To run the simulation, click the Start simulation button on the model window toolbar. You can use toolbar options to specify how long to run the simulation and to stop a running simulation.

While the simulation is running, the status bar at the bottom of the model window indicates the progress of the simulation. After the simulation finishes, check the directory in which you ran the simulation to verify that an AVI file was created.

  


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