cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tharaka27
Visitor
Visitor
669 Views
Registered: ‎12-26-2019

OpenCV compilation error in Vivado HLS 2018.3 csim

I was trying to run following code in the csimulation which was working fine few days back,

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

using namespace std;
using namespace cv;

int main(){


    Mat input_image = imread("C:\\Users\\ASUS\\Desktop\\sem 5 project\\ImageStitcherSIFT\\Data_FPGA\\left_r.jpg", 0);
    if(!input_image.data )
    {
       cout <<  "Could not open or find the image" << std::endl ;
      return -1;
    }

    namedWindow( "Display window", WINDOW_AUTOSIZE );
    Mat H = (Mat_<double>(3, 3) << 1, 0, 0, 0,1, 0, 0, 0, 1);
    Mat output_image;
    warpPerspective(input_image, output_image, H, cv::Size(input_image.cols, input_image.rows));
    imshow( "Display window", output_image );
    waitKey(0);

    return 0;
}

But it gave me an error and did not compile correctly.

obj/warptransform_tb.o: In function `cv::Mat_<double>::operator=(cv::Mat const&)':
C:/Xilinx2/Vivado/2018.3/include/opencv2/core/mat.inl.hpp:1716: undefined reference to `cv::error(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, char const*, int)'
collect2.exe: error: ld returned 1 exit status
make: *** [csim.exe] Error 1
ERROR: [SIM 211-100] CSim file generation failed: compilation error(s).

After that, I created a new project in vivado hls 2018.3 and added the same files in the previous project which compiled fine. 

I saw a similar situation in this in HLS 2018.2 

Any idea why is this happening?

0 Kudos
3 Replies
wenchen
Moderator
Moderator
580 Views
Registered: ‎05-27-2018

Hi @tharaka27 ,

It seems that you want to test a totally OpenCV function instead of using xfopencv. So you may check your static library linking problem in your environment.

In HLS, the Edit CFLAGS button specifies the C compiler flags options required to compile the C code.
These compiler flag options are the same used in gcc or g++. C compiler flags include the path name to header files, macro specifications, and compiler directives, as shown in the following examples:
• -I/project/source/headers: Provides the search path to associated header files

Note: You must specify relative path names in relation to the working directory not the project directory.

UG902 page24

Wen

-------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.


**~ Got a minute? Answer our Vitis HLS survey here! ~**


-------------------------------------------------------------------------
如果提供的信息能解决您的问题,请标记为“接受为解决方案”。
如果您认为帖子有帮助,请点击“奖励”。谢谢!
-------------------------------------------------------------------------------------------------
0 Kudos
tharaka27
Visitor
Visitor
565 Views
Registered: ‎12-26-2019

Thank you @wenchen . I will check and let you know

0 Kudos
scampbell
Moderator
Moderator
405 Views
Registered: ‎10-04-2011

Hello @tharaka27 ,

 

The hls_video.h library has been deprecated in the 2019.1 release, and the Vitis Vision library will provide all accelerated video functionality going forward. This library is located here:

https://github.com/Xilinx/Vitis_Libraries/tree/master/vision

 

In versions prior to 2020.1, we provided an installation of OpenCV 2.x in the Vitis and Vivado installation directories. However, in 2020.1, we no longer provide this library in order to allow users to install the version of their choice, and to avoid version conflicts. This requires the user to install the OpenCV library, and provide environment variables pointing to that installation. In addition, we require multiple references to the OpenCV library for the HLS tools for C Simulation and CoSimulation, and the Vision Library for IP compilation. Note that the OpenCV installation is only necessary for testbench verification, and is not required in any way for kernel synthesis in HLS.

I have created a sticky post which highlights the process of setting up the environment and creating a TCL script to use the OpenCV library for the Vision Library L1 resize example. I recommend running this first, then using the project that is created for GUI development if you wish. That post is here:
https://forums.xilinx.com/t5/High-Level-Synthesis-HLS/Using-Vitis-Vision-Libraries-and-OpenCV/td-p/1170435

 

Although your flow is slightly different, you should be able to modify that script for your older flow to point to the appropriate libraries, however, because that flow is deprecated, I recommend upgrading to the Vitis Vision flow.

 

OK, I hope this helps,
Scott