The From Video Device block supports code generation with Simulink® Coder™. Generating code from the From Video Device block enables you to run models containing the block in Accelerator, Rapid Accelerator, and Deployed modes.
A typical workflow for code generation follows.
Develop a model using the From Video Device block and sink blocks from other toolboxes, such as the Computer Vision Toolbox™.
Run the simulation to verify that your device is working.
Build the model to generate code and create the executable.
The deployed application can then be used on a machine that does not have MATLAB® and Simulink.
You can use Image Acquisition Toolbox™, Simulink Coder, and Embedded Coder® 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 the Simulink Coder documentation.
If you use a GigE Vision® camera with the From Video Device block, you must install GenICam™ to use the generated application outside of MATLAB. After you install the GenICam driver, load the DLL files by manually adding the path to the DLL files to the system path (in Control Panel > System > Advanced system settings > Environment Variables...) .
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. Simulink
Coder 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, run the following code in the MATLAB Command Window.
In this example,
gcs is the current model that you want to
build. Building the model creates a zip file with the same name as the model name.
You can move this zip file to another machine and build the source code in the zip
file to create an executable that can run independent of MATLAB and Simulink. For more information, see
The From Video Device block supports the use of Simulink Rapid Accelerator mode and code generation on Windows® platforms. Code generation is also supported on Linux®, but Rapid Accelerator mode is not.
If you get a “Device in use” error message when using the block with certain hardware, such as Matrox®, close any programs that are using the hardware, and try using the block again.
On Linux platforms, you need to add the directory where you unzip the
libraries to the environment variable