Implementing Algorithm in Model Composer - 2021.1 English

Vitis Model Composer Tutorial: (UG1498)

Document ID
Release Date
2021.1 English
  1. In the MATLAB Current Folder, navigate to \HLS_Library\Lab1\Section1.
  2. Double-click the Sobel_EdgeDetection_start.slx model.

    This model already contains source and sink blocks to stream video files as input directly into your algorithm and view the results. The model also contains some of the needed HLS blocks required for this section. Note the difference in appearance for the HLS blocks in the design versus the Simulink blocks.

  3. Double-click Sobeledge_lib.slx library model and and drag the SobelFilter_XMC block into the area labeled Convolve Image Frame with Sobel Kernel and Compute Gradient as shown in the following figure and connect the input of this block to the output of the From Multimedia File block.
  4. Select the GradientMag_XMC block from the Sobeledge_lib.slx file and drag it into the model, and connect the X and Y outputs of the Sobel Filter block to the input of this block.
  5. Connect the rest of the blocks to complete the algorithm as shown in the following figure.
    Note: The blocks SobelFilter_XMC and GradientMag_XMC have been generated using the xmcImportFunction feature.

  6. Select the Simulation > Run command or click the button to simulate the model and view the results of the Sobel Edge Detection algorithm.
    Note: The Model Composer blocks can operate on matrices (image frames in the following figure).

    One way to assess the simulation performance of the algorithm is to check the video frame rate of the simulation. To do this:

  7. Add the Frame Rate Display block from the Simulink Computer Vision System Toolbox (under the Sinks category) and connect it to the output of the algorithm as shown in the following figure.
  8. Simulate the model again to see the number of video frames processed per second.

  9. Try these changing the input video through the From Multimedia File block by double-clicking the block and changing the File Name field to select a different video. Notice that changing the video resolution in the Source block does not require any structural modifications to the algorithm itself.
    Note: You must stop simulation before you can change the input file. Also, the .mp4 files in the MATLAB vision data tool box directory are not supported.