Display an image is one of the common tasks in embedded system applications, including applications running on embedded FPGA systems such as Zynq MPSoC.

Vitis is the application development environment for Zynq MPSoC. We can use the OpenCV library in Vitis to manipulate images and display them on screen.

Here I will show how to do that.

1- Create a Vitis project

 2- Choose the proper platform

3- Type the project name

4- Here, I choose the “Empty Application (C++)” template. You can select other template types based on your project.

Online Courses on HLS for FPGA

If you are interested in learning high-level synthesis for FPGA, please refer to my online course.

5- Create a new file under the src folder, with the name of “display_image.cpp”

6- Write this code inside the created file

#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{

    // Read the image file
    Mat image = imread("./test.jpg");

    // Check for failure
    if (image.empty()) {
        cout << "Could not open or find the test.jpg image" << endl;
        return -1;
    }

    String windowName = "Display Image"; // Name of the window

    namedWindow(windowName); // Create a window

    imshow(windowName, image); // Show the image inside the created window.

    waitKey(0); // Wait for any keystroke in the window

    destroyWindow(windowName); //destroy the created window

    return 0;
}

7- Right-click on the “display_image-vitis” project and select properties, then go to settings–>libraries and add four OpenCV libraries and their path as shown in the following figure.

8- Now compile the code, transfer the generated binary file into the Ultra96v2 SDcard and run the program on the actual board.

9- You can use the program as a utility by modifying the code to get the image file name as a program argument.

Online Courses on HLS for FPGA

If you are interested in learning high-level synthesis for FPGA, please refer to my online course.

4 thoughts on “How to Display an Image in Vitis Running on Ultra96v2 FPGA Embedded System”
  1. Thanks for the interesting post!

    If I understand correctly, the code will run on the PS.
    Ia there an easy way to specify what will run on the PL?

Leave a Reply to MohammadCancel reply

Discover more from High-Level Synthesis & Embedded Systems

Subscribe now to keep reading and get access to the full archive.

Continue reading