integrate vision hdl blocks into camera link system -凯发k8网页登录
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.
structure of the model
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.
structure of the subsystem
the cameralink2vht
and 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.
import data in camera link format
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]);
convert camera link control signals to pixelcontrol format
write a custom system object to convert camera link signals to the vision hdl toolbox format. this example uses the object designed in the 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 cameralinktovht_adapter.m
.
create a matlab system block and point it to the system object.
design vision hdl toolbox algorithm
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.
convert pixelcontrol to camera link
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 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 vhttocameralinkadapter.m
.
create a second matlab system block and point it to the system object.
view results
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 (dsp system toolbox).
generate hdl code for subsystem
to generate hdl code you must have an hdl coder™ license.
to generate the hdl code, use the following command.
makehdl('cameralinkadapterex/cameralink_invertimage')
you can now simulate and synthesize these hdl files along with your existing camera link system.