cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Ztone
Adventurer
Adventurer
712 Views
Registered: ‎03-28-2020

how to complete the opencv resize Function in Vitis_Libraries_2019.2 using Vitis HLS

I want to complete the opencv image resize function by Vitis HLS.

I create an Vitis HLS project

First, import kernel source and add  CFLAGS as following:

-I/home/test/Vitis_Libraries-2019.2/vision/L1/include -I/home/test/Vitis_Libraries-2019.2/vision/L2/examples/resize -I/home/test/Vitis_Libraries-2019.2/vision/L2/tests/resize/resize_DOWN_NN_NO_RGB -D__SDSVHLS__ -std=c++0x

Second, import testbench and add CFLAGS as following:

-D__SDSVHLS__ -I../Vitis_Libraries-2019.2/vision/L1/include -I../Vitis_Libraries-2019.2/vision/L2/examples/resize -I../Vitis_Libraries-2019.2/vision/L2/tests/resize/resize_DOWN_NN_NO_RGB -I../Vitis_Libraries-2019.2/vision/ext/xcl2 -std=c++0x

Third, add Linker Flags in Simulation Dialog box as following:

-lopencv_core -lopencv_imgcodecs -lopencv_highgui -lopencv_imgproc -lopencv_videoio

The project structure is shown below:

project structureproject structure

Finally,I click the Run C Simulation Button to build this project, some error occurred as following shown:

Starting C simulation ...
/tools/Xilinx/Vitis/2019.2/bin/vitis_hls /home/test/vitis_hls_workspcae/resize_test/solution1/csim.tcl
INFO: [HLS 200-10] Running '/tools/Xilinx/Vitis/2019.2/bin/unwrapped/lnx64.o/vitis_hls'
INFO: [HLS 200-10] For user 'test' on host 'test-Legion-Y7000P-2019' (Linux_x86_64 version 4.15.0-118-generic) on Tue Oct 13 11:24:00 CST 2020
INFO: [HLS 200-10] On os Ubuntu 16.04.6 LTS
INFO: [HLS 200-10] In directory '/home/test/vitis_hls_workspcae'
Sourcing Tcl script '/home/test/vitis_hls_workspcae/resize_test/solution1/csim.tcl'
INFO: [HLS 200-10] Opening project '/home/test/vitis_hls_workspcae/resize_test'.
INFO: [HLS 200-10] Adding design file '../Vitis_Libraries-2019.2/vision/L2/tests/resize/resize_DOWN_NN_NO_RGB/xf_config_params.h' to the project
INFO: [HLS 200-10] Adding design file '../Vitis_Libraries-2019.2/vision/L2/examples/resize/xf_resize_accel.cpp' to the project
INFO: [HLS 200-10] Adding design file '../Vitis_Libraries-2019.2/vision/L2/examples/resize/xf_resize_config.h' to the project
INFO: [HLS 200-10] Adding test bench file '../Vitis_Libraries-2019.2/vision/L2/examples/resize/xf_resize_tb.cpp' to the project
INFO: [HLS 200-10] Opening solution '/home/test/vitis_hls_workspcae/resize_test/solution1'.
INFO: [SYN 201-201] Setting up clock 'default' with a period of 10ns.
INFO: [HLS 200-10] Setting target device to 'xczu7ev-ffvc1156-2-e'
INFO: [SYN 201-201] Setting up clock 'default' with a period of 10ns.
INFO: [SIM 211-2] *************** CSIM start ***************
INFO: [SIM 211-4] CSIM will launch GCC as the compiler.
Generating csim.exe
Makefile.rules:333: recipe for target 'csim.exe' failed
/tools/Xilinx/Vivado/2019.2/tps/lnx64/binutils-2.26/bin/ld: warning: libopencv_core.so.3.4, needed by /usr/local/lib/libopencv_imgcodecs.so, may conflict with libopencv_core.so.2.4
/tools/Xilinx/Vivado/2019.2/tps/lnx64/binutils-2.26/bin/ld: obj/xf_resize_tb.o: undefined reference to symbol '_ZN2cv6String10deallocateEv'
/usr/local/lib/libopencv_core.so.3.4: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [csim.exe] Error 1
ERROR: [SIM 211-100] 'csim_design' failed: compilation error(s).
INFO: [SIM 211-3] *************** CSIM finish ***************
4
while executing
"source /home/test/vitis_hls_workspcae/resize_test/solution1/csim.tcl"
invoked from within
"hls::main /home/test/vitis_hls_workspcae/resize_test/solution1/csim.tcl"
("uplevel" body line 1)
invoked from within
"uplevel 1 hls::main {*}$args"
(procedure "hls_proc" line 5)
invoked from within
"hls_proc $argv"
Finished C simulation.

 

Am I missing some key steps???

How to solve this problem???

Looking forward to your review and reply!!!

0 Kudos
2 Replies
scampbell
Moderator
Moderator
590 Views
Registered: ‎10-04-2011

Hello @Ztone ,

The installation and use of the Vitis Vision libraries and OpenCV inside Vitis HLS is a complex one requiring many compiler options to be set correctly. One thing I will note before going into detail is that OpenCV is required *only* for simulation, and does not affect the kernel synthesis in any way. I wrote a sticky post describing how to setup the environment for OpenCV and to create a standalone Vitis HLS project which references OpenCV and the Vitis Vision libraries for the L1 resize example design. That is located here:

https://forums.xilinx.com/t5/High-Level-Synthesis-HLS/Using-Vitis-Vision-Libraries-and-OpenCV/td-p/1170435

Looking at your images, and OpenCV library error, I think the OpenCV include are missing, and maybe the linker commands for C Sim/CoSim are missing. If you look at my post, can you see if that helps you resolve this issue? I would recommend running the TCL first to ensure all flags are correct, then using the project created from that in the GUI for further development. 

OK, I hope this helps, and please let me know so I can update that post if anything is missing.

Scott

0 Kudos
Ztone
Adventurer
Adventurer
538 Views
Registered: ‎03-28-2020

When I do C Synthesis in Vitis Hls,The Following error is occur



INFO: [HLS 214-131] Inlining function 'void xf::cv::Array2xfMat<128, 9, 128, 128, 1>(ap_uint<128>*, xf::cv::Mat<9, 128, 128, 1>&)' into 'resize_accel' (xf_resize_accel.cpp:50:5)
INFO: [HLS 214-131] Inlining function 'void xf::cv::xfMat2Array<128, 9, 64, 64, 1>(xf::cv::Mat<9, 64, 64, 1>&, ap_uint<128>*)' into 'resize_accel' (xf_resize_accel.cpp:52:5)
ERROR: [HLS 214-134] in function 'void xf::cv::accel_utils::hlsStrm2xfMat<128, 9, 128, 128, 1, 16384>(hls::stream<ap_uint<128>, 0>&, xf::cv::Mat<9, 128, 128, 1>&, int)': Pointer to pointer is not supported
WARNING: [HLS 214-167] The program may have out of bound array access (../../Vitis_Libraries-2019.2/vision/L1/include/imgproc/xf_resize_down_area.hpp:324:13)
ERROR: [HLS 214-134] in function 'void xFResizeAreaDownScale<128, 128, 3, 9, 1, 9, 64, 64, 128, 64>(xf::cv::Mat<9, 128, 128, 1>&, xf::cv::Mat<9, 64, 64, 1>&)': Pointer to pointer is not supported
ERROR: [HLS 214-134] in function 'void xFResizeAreaDownScale<128, 128, 3, 9, 1, 9, 64, 64, 128, 64>(xf::cv::Mat<9, 128, 128, 1>&, xf::cv::Mat<9, 64, 64, 1>&)': Pointer to pointer is not supported
ERROR: [HLS 214-134] in function 'void xf::cv::accel_utils::xfMat2hlsStrm<128, 9, 64, 64, 1, 4096>(xf::cv::Mat<9, 64, 64, 1>&, hls::stream<ap_uint<128>, 0>&, int)': Pointer to pointer is not supported
ERROR: [HLS 214-135] Syn check fail!
WARNING: [HLS 200-651] Found issues in source files:
error: ../../Vitis_Libraries-2019.2/vision/L1/include/common/xf_structs.hpp:529:9: in function 'resize_accel': Undefined function xf::cv::_ssdm_op_alloc
error: ../../Vitis_Libraries-2019.2/vision/L1/include/common/xf_structs.hpp:529:9: in function 'resize_accel': Undefined function xf::cv::_ssdm_op_alloc
error: <unknown>:0:0: in function 'void xf::cv::accel_utils::hlsStrm2xfMat<128, 9, 128, 128, 1, 16384>(hls::stream<ap_uint<128>, 0>&, xf::cv::Mat<9, 128, 128, 1>&, int)': Pointer to pointer is not supported
warning: ../../Vitis_Libraries-2019.2/vision/L1/include/imgproc/xf_resize_down_area.hpp:324:13: The program may have out of bound array access
error: <unknown>:0:0: in function 'void xFResizeAreaDownScale<128, 128, 3, 9, 1, 9, 64, 64, 128, 64>(xf::cv::Mat<9, 128, 128, 1>&, xf::cv::Mat<9, 64, 64, 1>&)': Pointer to pointer is not supported
error: <unknown>:0:0: in function 'void xFResizeAreaDownScale<128, 128, 3, 9, 1, 9, 64, 64, 128, 64>(xf::cv::Mat<9, 128, 128, 1>&, xf::cv::Mat<9, 64, 64, 1>&)': Pointer to pointer is not supported
error: <unknown>:0:0: in function 'void xf::cv::accel_utils::xfMat2hlsStrm<128, 9, 64, 64, 1, 4096>(xf::cv::Mat<9, 64, 64, 1>&, hls::stream<ap_uint<128>, 0>&, int)': Pointer to pointer is not supported
error: Syn check fail!


Pre-synthesis failed.
while executing
"source /home/test/vitis_hls_workspcae/resize_test/project_resize_test/solution1/csynth.tcl"
invoked from within
"hls::main /home/test/vitis_hls_workspcae/resize_test/project_resize_test/solution1/csynth.tcl"
("uplevel" body line 1)
invoked from within
"uplevel 1 hls::main {*}$args"
(procedure "hls_proc" line 5)
invoked from within
"hls_proc $argv"
Finished C synthesis.


I add the kernel file and testbench file as following shown

add_files ${XF_PROJ_ROOT}/L1/examples/resize/xf_resize_accel.cpp -cflags "-I${XF_PROJ_ROOT}/L1/include -I ./ -D__SDSVHLS__ -std=c++0x" -csimflags "-I${XF_PROJ_ROOT}/L1/include -I ./ -D__SDSVHLS__ -std=c++0x"
add_files -tb ${XF_PROJ_ROOT}/L1/examples/resize/xf_resize_tb.cpp -cflags "-I${XF_PROJ_ROOT}/L1/include -I ./ -D__SDSVHLS__ -std=c++0x" -csimflags "-I${XF_PROJ_ROOT}/L1/include -I ./ -D__SDSVHLS__ -std=c++0x"


How to solve this problem, when I use the Makefile to make CSYNTH=1,it's work. How to solve this problem in Vitis HLS GUI
0 Kudos