OpenCV basic tutorial for computer vision applications

From industrial inspection systems to automated driving systems, computer vision is a broad field that includes many interesting applications. Many of these systems use the Open Source Computer Vision Library (OpenCV) for both the prototype and implementation phases. OpenCV optimizes many of the functional functions and is used in real-time computer vision programs. However, due to the unique advantages of the embedded optimization strategy, it is still worth trying to use the logic hardware to accelerate the performance of OpenCV.

Currently, OpenCV is widely used in the development of computer vision applications. OpenCV includes a library of more than 2,500 optimized video functions and is optimized for desktop processors and graphics processing units (GPUs).

Xilinx's Vivado HLS high-level synthesis tool can directly create RTL hardware through C/C++ code to significantly improve design efficiency. At the same time, Xilinx Zynq fully programmable SOC series devices embed dual-core ARM Cortex-A9 processor with software programmability It combines with the hardware programmability of the FPGA to achieve unparalleled system performance, flexibility, scalability and speed up the time-to-market of graphics processing products with system power advantages such as low power consumption and low cost. OpenCV has thousands of users, and the OpenCV design runs on the ARM processor of the Zynq device without modification. However, HD processing using OpenCV is often limited by external memory, especially storage bandwidth can become a performance bottleneck, and storage access also limits power efficiency. With the Vivado HLS high-level language synthesis tool from Xilinx, designers can easily convert OpenCV C++ video processing designs to RTL code and convert them into hardware accelerators that can be implemented in Zynq or real-time hardware video processing units implemented on FPGAs. .

1, OpenCV and HLS video library

As shown in Figure 15.83, OpenCV can be used in different ways in video processing systems. In Figure 15.83(a), the design and implementation of the algorithm relies entirely on OpenCV function calls, using the file access function for image input, output, and processing; in Figure 15.83(b), the algorithm can be used in an embedded system ( For example, implementation in Zynq Base TRD) uses a platform-specific function call to access input and output images. However, the implementation of video processing relies on calls from OpenCV function functions by processors (such as CortexTM-A9) in embedded systems; Figure 15.83 In (c), the OpenCV function of the processing algorithm is replaced by the Xilinx Vivado HLS video library function, while the OpenCV function is used to access the input and output images, providing a design prototype for the implementation of the video processing algorithm. The video library functions provided by Vivado HLS can be synthesized, and after integrating these functions, the processor modules can be integrated into programmable logic such as Zynq. In this way, these program logic blocks can process the video stream produced by the processor, the data read from the file, and the externally input real-time video stream.

Figure 15.83 Different ways of OpenCV application

Figure 15.83 Different ways of OpenCV application

Vivado HLS includes a large number of video library functions to facilitate the construction of a wide variety of video processing programs. These video library functions are implemented in synthesizable C++ code. In terms of video processing functions and data structures, these integrated codes basically correspond to OpenCV. Many video concepts are very similar to abstraction and OpenCV, and many image processing module functions are consistent with OpenCV library functions.

For example, one of the most important classes used to represent images in OpenCV is the cv::Mat class. The cv::Mat object is defined as follows:
Cv::Mat image(1080, 1920, CV_8UC3);

This line of code declares a 1080 & TImes; 1920 pixels, each pixel is a variable image represented by three 8-bit unsigned numbers. The corresponding HLS video library template class hls::Mat<> is declared as follows:
Hls::Mat<2047, 2047, HLS_8UC3> image(1080, 1920);

The two lines of code have different parameter forms, maximum image size, and grammar rules, and the generated objects are similar. If the maximum size specified by the image is the same as the actual size of the image, you can also use the following code instead:
Hls::Mat<1080, 1920, HLS_8UC3> image( );

Table 15.14 shows a simple image conversion function application comparison (function implementation dst=src*2.0+0.0).

The core structure and HLS video library for OpenCV and HLS video libraries are given in Table 15.15 and Table 15.16.

OpenCV basic tutorial for computer vision applications

OpenCV basic tutorial for computer vision applications

2, AXI4 stream and video interface

Through the AXI4 streaming protocol, the video processing module provided by Xilinx implements pixel data communication. Although the underlying AXI4 streaming protocol does not need to limit the image size, if the image size is the same, it will greatly simplify most of the complex video processing calculations. For input interfaces that follow the AXI4 streaming protocol, it is guaranteed that each frame contains ROWS * COLS pixels. Subsequent modules enable efficient processing of video frames while ensuring that the previous video frames remain intact and rectangular.

As shown in Table 15.17, the Vivado HLS contains two synthesizable video interface conversion functions.

Disposable Vape

Disposable Vape,Disposable Vape Pen,Disposable Vape Elf Bar Lux,Disposable Vape Pod Device

Shenzhen Zpal Technology Co.,Ltd , https://www.zpal-vape.com