Overview
This document describes the FPGA device optimizedxfOpenCVlibrary, called theXilinx®xfOpenCVlibrary and is intended for application developers usingZynq®-7000 SoCandZynq® UltraScale+™ MPSoCand PCIE based (Virtex and U200 ...) devices.xfOpenCVlibrary has been designed to work in theSDx™development environment, and provides a software interface for computer vision functions accelerated on an FPGA device.xfOpenCVlibrary functions are mostly similar in functionality to theirOpenCVequivalent. Any deviations, if present, are documented.
Basic Features
AllxfOpenCVlibrary functions follow a common format. The following properties hold true for all the functions.
- All the functions are designed as templates and all arguments that are images, must be provided as
xf::Mat
. - All functions are defined in the
xf
namespace. - Some of the major template arguments are:
- Maximum size of the image to be processed
- Datatype defining the properties of each pixel
- Number of pixels to be processed per clock cycle
- Other compile-time arguments relevent to the functionality.
ThexfOpenCVlibrary contains enumerated datatypes which enables you to configurexf::Mat
. For more details onxf::Mat
, see thexf::Mat Image Container Class.
xfOpenCV Kernel on the reVISION Platform
ThexfOpenCVlibrary is designed to be used with theSDxdevelopment environment.xfOpenCVkernels are evaluated on the reVISION platform.
The following steps describe the general flow of an example design, where both the input and the output are image files.
- Read the image using
cv::imread()
. - Copy the data to
xf::Mat
. - Call the processing function(s) inxfOpenCV.
- Copy the data from
xf::Mat
tocv::Mat
. - Write the output to image using
cv::imwrite()
.
The entire code is written as the host code for the pipeline , from which all the calls toxfOpenCVfunctions are moved to hardware. Functions fromxfOpenCVare used to read and write images in the memory. The image containers forxfOpenCVlibrary functions arexf::Mat
objects. For more information, see thexf::Mat Image Container Class.
- File I/O mode enables the controller to transfer images from SD Card to the hardware kernel. The following steps describe the file I/O mode.
- Processing system (PS) reads the image frame from the SD Card and stores it in the DRAM.
- ThexfOpenCVkernel reads the image from the DRAM, processes it and stores the output back in the DRAM memory.
- The PS reads the output image frame from the DRAM and writes it back to the SD Card.
- Live I/O mode enables streaming frames into the platform, processing frames with thexfOpenCVkernel, and streaming out the frames through the appropriate interface. The following steps describe the live I/O mode.
- Video capture IPs receive a frame and store it in the DRAM.
- ThexfOpenCVkernel fetches the image from the DRAM, processes the image, and stores the output in the DRAM.
- Display IPs read the output frame from the DRAM and transmits the frame through the appropriate display interface.
Following figure shows the reVISION platform with thexfOpenCVkernel block:
xfOpenCV Library Contents
The following table lists the contents of thexfOpenCVlibrary.
Folder | Details |
---|---|
include | Contains the header files required by the library. |
include/common | Contains the common library infrastructure headers, such as types specific to the library. |
include/core | Contains the core library functionality headers, such as themath functions. |
include/features | Contains the feature extraction kernel function definitions. For example,Harris . |
include/imgproc | Contains all the kernel function definitions, except the ones available in thefeaturesfolder. |
include/video | Contains all the kernel function definitions, except the ones available in thefeatures and imgprocfolder. |
examples | Contains the sample test bench code to facilitate running unit tests. Theexamples/folder contains the folders with algorithm names. Each algorithm folder contains host files,.jsonfile, anddatafolder. For more details on how to use the xfOpenCV library, seexfOpenCV Kernel on the reVISION Platform. |
examples | Contains the sample test bench code for 24 functions, which shows how to use xfOpenCV library inSDAccel™environment. |
HLS_Use_Model | Contains examples for using xfOpenCV functions in Standalone Vivado HLS in 2 different modes. |
HLS_Use_Model/Standalone_HLS_Example | Contains sample code and tcl script for synthesizing xfOpenCV functions as is, in Standalone Vivado HLS tool. |
HLS_Use_Model/Standalone_HLS_AXI_Example | Contains sample code and tcl script for synthesizing functions with AXI interfaces, in Standalone Vivado HLS tool. |