Having previously created a simple transparent image processing pipeline with the Zybo Z7, in this blog I am going to look at how we can implement our image processing algorithms using High Level Synthesis (HLS).
HLS allows us to work at a higher level of abstraction, using C and C++ to implement our image processing algorithms or indeed many other algorithms. As such when we get a much faster development time, the HLS tool itself generates the Verilog or VHDL implementation of our desired functionality.
One of the big benefits in using HLS is that, as we can also develop our algorithms in C or C++, we not only leverage industry standard frameworks and libraries, but can also benefit from a much faster simulation time.
When it comes to working with the Zynq or the Zynq MPSoC, we can leverage the power of HLS using either a HLx or SDx flow.
For the moment, since we are working with a bare metal operating system on the Zybo Z7, we will focus upon the HLx flow which creates IP cores we can add into our Vivado design.
We will look at the SDx flow in-depth in a later blog. However, the SDx flow can briefly be described as providing system level optimization, enabling the developer to move functions seamlessly between the Processing System (PS) and the Programmable Logic (PL).
To create our HLx image processing application, we can use the following libraries designed for accelerating image processing applications:
- Use the inbuilt HLS video libraries, HLS_Video.h and HLS_opencv.h which provides several functions that can be synthesized to logic (HLS_Video.h) along with providing the necessary interfaces with OpenCV (HLS_opencv.h) to create test benches simply.
- Add in the xfOpenCV library from the Xilinx GitHub into Vivado HLx. The xfOpenCV library provides 50 plus OpenCV functions which can be accelerated into logic.
Both these libraries provide us the ability to accelerate a wide range of image processing functions that can be grouped:
- Basic functionality, e.g. colour conversion, bit and pixelwise operations, erosion and dilation.
- Geometric transformation, e.g. Scale/ reSize, Warp and Remap
- Image processing and filtering, e.g. Sobel, Histogram, Convolution
- Feature detection and classification, e.g. Canny edge, Harris Corner, HOG, SVM
- 3D reconstruction, e.g. StereoLBM
- Motion analysis and tracking, e.g. Mean shift tracking and LK Dense Optical Flow
The main difference between a traditional OpenCV flow and an accelerated function is the method in which pixels are addressed. Using OpenCV the image is stored in memory as such pixels are randomly addressable. Such an approach would be inefficient for a programmable logic based solution. As such accelerated functions process images as streams of pixels which also helps increase the performance.
Having introduced the Vivado HLx flow and the libraries available to us, let’s take a look at how we can use Vivado HLx to accelerate our image processing application.
See My FPGA / SoC Projects: Adam Taylor on Hackster.io
Get the Code: ATaylorCEngFIET (Adam Taylor)
Additional Information on Xilinx FPGA / SoC Development can be found weekly on MicroZed Chronicles.