Install VITIS_HLS2021.2 on ubuntu20.04 to configure OPENCV4.4 and VITIS_LIBRARIES (detailed version)

I. Introduction

Hello everyone, I will configure this VITIS_HLS for fellow researchers today, because I have experienced too many ups and downs, in order to let everyone understand the troubles of configuring the environment, I will publish a detailed version, I hope you like it

2. Installation of VITIS

My previous blog has already published the installation of vitis, so I won’t go into details here, just give the link to my blog directly, please don’t use the opencv installation inside, I will explain the installation of opencv in the third section (this huge pit)

Detailed tutorial for VITIS installation

3. Installation of opencv

Step 1: Principle (Tucao Conference)

Here I would like to complain a few words, because the installation of this opencv has really troubled me for a few days, and I have a splitting headache. I repeatedly deleted the installation, which made my head very big, but it was finally solved today. Let me complain about what I encountered. question:

/usr/local/lib/libopencv_core.so: undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream()@GLIBCXX_3.4.26'
collect2: error: ld returned 1 exit status

This is the problem I have encountered. If you do not follow my opencv installation tutorial to install, you will encounter this problem with a high probability, and I can say arrogantly that you generally cannot solve this problem. There are various solutions on the Internet. It just can't be solved, don't pretend, let me explain the reason.

When we install opencv, we usually use the g++ (9.4) compiler that comes with ubuntu to compile, and then we need to combine opencv with HLS, but the g++ compiler that comes with HLS seems to be 6.20, so the problem comes. How can things compiled with different versions of the compiler be built together? Don't pretend anymore, let's get to the topic below.

Step 2: Download and install opencv4.4.0

1. Download opencv4.4.0 and contrib version

The download link is directly given here for your convenience ==>> oepcv4.4 package

Note: It must be opencv4.4, do not download other versions randomly, because this version has been tested by xilinx across the board.

2. Unzip and install dependencies

Extract the downloaded compressed package to the main directory, and create a new folder (opencv), and put the decompressed files into this folder, as shown in the figure:

 After opening, as shown in the picture, one is opencv4.4, and the other is opencv4.4_contrib. For convenience, I renamed it as shown in the picture.

 To install dependencies, open a terminal and enter the following command:

 sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
 sudo apt update
 sudo apt-get install build-essential
 sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libopenexr-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
 sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
 sudo apt update
 sudo apt-get install python-dev-is-python3 python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper1 libjasper-dev libdc1394-22-dev

3. Install opencv

After the installation is complete, enter the opencv/opencv folder and create a build folder:

cd opencv/opencv
mkdir build
cd build
export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:$LIBRARY_PATH

Then run the following command: (replace directory with your own settings)

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=<choose your own output directory> -D WITH_V4L=ON -D OPENCV_EXTRA_MODULES_PATH=<point to opencv_contrib>/modules -DBUILD_TESTS=OFF -DBUILD_ZLIB=ON -DBUILD_JPEG=ON -DWITH_JPEG=ON -DWITH_PNG=ON -DBUILD_EXAMPLES=OFF -DINSTALL_C_EXAMPLES=OFF -DINSTALL_PYTHON_EXAMPLES=OFF -DWITH_OPENEXR=OFF -DBUILD_OPENEXR=OFF -D CMAKE_CXX_COMPILER=<path to Vitis_HLS>/Vitis_HLS/2021.2/tps/lnx64/gcc-6.2.0/bin/g++ ..

Note: This contains

<choose your own output directory>, please replace it with your own path, the following is my own path, for reference only
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/opencv -D WITH_V4L=ON -D OPENCV_EXTRA_MODULES_PATH=/home/wind/opencv/opencv_contrib/modules -DBUILD_TESTS=OFF -DBUILD_ZLIB=ON -DBUILD_JPEG=ON -DWITH_JPEG=ON -DWITH_PNG=ON -DBUILD_EXAMPLES=OFF -DINSTALL_C_EXAMPLES=OFF -DINSTALL_PYTHON_EXAMPLES=OFF -DWITH_OPENEXR=OFF -DBUILD_OPENEXR=OFF -D CMAKE_CXX_COMPILER=/tools/Xilinx/Vitis_HLS/2021.2/tps/lnx64/gcc-6.2.0/bin/g++ ..

Then continue to enter: (I have 16 cores, so it is j16)

make -j16

Note: There may be problems here, what boost files are missing, I have given these files above, please copy all of them to the opencv_contrib/modules/xfeatures2d/src/ directory, as shown in the figure:

 Then enter on the command line:

make clean
make -j16
sudo make install

At this point, the opencv installation has been completed, and the link to the reference article is given here: vitis library compilation

4. Configuration of VITIS_HLS and VITIS_LIBRARIES

Step 1: Download VITIS_LIBRARIES

The download link is directly given here for your convenience ===>>>> VITIS_LIBRARIES

After you download it, unzip it to the main directory for backup.

Step 2: VITIS_HLS configures opencv and VITIS_LIBRARIES

Open VITIS_HLS, create a new project, as shown in the figure

1. Open vitis_hls

2. Create a new project

 

 

 

 

 3. After the creation is complete, add the cpp file in the source and testbench, and add a picture in the testbench

4. The content of ceshi.cpp is shown in the figure above, and the content of main.cpp is shown in the figure below

 

 5. Open project->project settings, click simulation

6. After clicking main.cpp, click Edit CFLAGS

 

7. Enter the following:

-I<path-to-L1-include-directory> -std=c++0x -I<path-to-opencv-include-folder>

Note: Change the file path to your own path, one is the include path of L1 in vitis_libraries, and the other is the include path of opencv. Here is my own path for reference only:

-I/home/wind/Vitis_Libraries-2021.2/vision/L1/include -std=c++0x -I/usr/local/opencv/include

 8. Enter the following content in the Linker Flags below:

-L<path-to-opencv-lib-folder> -lopencv_core -lopencv_imgcodecs -lopencv_imgproc

Note: Change the file path to your own path, which is the library path of opencv. Here is my own path for reference only:

-L/usr/local/opencv/lib -lopencv_core -lopencv_imgcodecs -lopencv_imgproc

 9. Click synthesis, click ceshi.cpp, select top function, select ceshi

 10. Click ceshi.cpp again, click Edit CFLAGS, and enter the following:

-I<path-to-L1-include-directory> -std=c++0x 

Here is my path for reference only:

-I/home/wind/Vitis_Libraries-2021.2/vision/L1/include -std=c++0x 

11. After all configurations are completed, click ok

 

At this point, the configuration has been fully completed, and the following enters the test link!

step 3: Test (color image to gray image) 

1. Open main.cpp, enter the following content: and save (crtl + s)

 2. Click run c simulation

 3. The following picture appears:

 4. The simulation is successful, and the picture is saved under this project file, soultion1->csim->build, as shown in the figure

This is the end, the configuration is complete! 

5. References

1、vitis_libraries

2. Opencv library compilation

3. Detailed installation video

Guess you like

Origin blog.csdn.net/weixin_56566649/article/details/125620148