This example shows how to design a Vision HDL Toolbox algorithm for integration into an existing system that uses the Camera Link® signal protocol.
Vision HDL Toolbox™ blocks use a custom streaming video format. If you integrate Vision HDL Toolbox algorithms into existing design and verification code that operates in a different streaming video format, you must convert the control signals at the boundaries. The example uses custom System objects to convert the control signals between the Camera Link format and the Vision HDL Toolbox
pixelcontrol format. The model imports the System objects to Simulink® by using the MATLAB System block.
This model imports pixel data and control signals in the Camera Link format from the MATLAB® workspace. The
CameraLink_InvertImage subsystem is designed for integration into existing systems that use Camera Link protocol. The
CameraLink_InvertImage subsystem converts the control signals from the Camera Link format to the
pixelcontrol format, modifies the pixel data using the Lookup Table block, and then converts the control signals back to the Camera Link format. The model exports the resulting data and control signals to workspace variables.
VHT2CameraLink blocks are MATLAB System blocks that point to custom System objects. The objects convert between Camera Link signals and the
pixelcontrol format used by Vision HDL Toolbox blocks and objects.
You can put any combination of Vision HDL Toolbox blocks into the middle of the subsystem. This example uses an inversion Lookup Table.
You can generate HDL from this subsystem.
Camera Link consists of three control signals: F indicates the valid frame, L indicates each valid line, and D indicates each valid pixel. For this example, the input data and control signals are defined in the
InitFcn callback. The vectors describe this 2-by-3, 8-bit grayscale frame. In the figure, the active image area is in the dashed rectangle, and the inactive pixels surround it. The pixels are labeled with their grayscale values.
FIn = logical([0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0]); LIn = logical([0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0]); DIn = logical([0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0]); pixIn = uint8([0,0,0,0,0,0,0,30,60,90,0,0,0,120,150,180,0,0,0,0,0,0,0,0]);
Write a custom System object to convert Camera Link signals to the Vision HDL Toolbox format. This example uses the object designed in the Convert Camera Control Signals to pixelcontrol Format example.
The object converts the control signals, and then creates a structure that contains the new control signals. When the object is included in a MATLAB System block, the block translates this structure into the bus format expected by Vision HDL Toolbox blocks. For the complete code for the System object, see
Create a MATLAB System block and point it to the System object.
Select Vision HDL Toolbox blocks to process the video stream. These blocks accept and return a scalar pixel value and a
pixelcontrol bus that contains the associated control signals. This standard interface makes it easy to connect blocks from the Vision HDL Toolbox libraries together.
This example uses the Lookup Table block to invert each pixel in the test image. Set the table data to the reverse of the
uint8 grayscale color space.
Write a custom System object to convert Vision HDL Toolbox signals back to the Camera Link format. This example uses the object designed in the Convert Camera Control Signals to pixelcontrol Format example.
The object accepts a structure of control signals. When you include the object in a MATLAB System block, the block translates the input
pixelcontrol bus into this structure. Then it computes the equivalent Camera Link signals. For the complete code for the System object, see
Create a second MATLAB System block and point it to the System object.
Run the simulation. The resulting vectors represent this inverted 2-by-3, 8-bit grayscale frame. In the figure, the active image area is in the dashed rectangle, and the inactive pixels surround it. The pixels are labeled with their grayscale values.
If you have a DSP System Toolbox™ license, you can view the signals over time using the Logic Analyzer. Select all the signals in the
CameraLink_InvertImage subsystem for streaming, and open the Logic Analyzer. This waveform shows the input and output Camera Link control signals and pixel values at the top, and the input and output of the Lookup Table block in
pixelcontrol format at the bottom. The
pixelcontrol busses are expanded to observe the boolean control signals.
For more info on observing waveforms in Simulink, see Inspect and Measure Transitions Using the Logic Analyzer (DSP System Toolbox).
To generate HDL code you must have an HDL Coder™ license.
To generate the HDL code, use the following command.
You can now simulate and synthesize these HDL files along with your existing Camera Link system.