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.

Note:For more information on the xfOpenCVlibrary prerequisites, see the Prerequisites. To familiarize yourself with the steps required to use the xfOpenCVlibrary functions, see the Using the xfOpenCV Library.

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 asxf::Mat.
  • All functions are defined in thexfnamespace.
  • 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.

  1. Read the image usingcv::imread().
  2. Copy the data toxf::Mat.
  3. Call the processing function(s) inxfOpenCV.
  4. Copy the data fromxf::Mattocv::Mat.
  5. Write the output to image usingcv::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::Matobjects. For more information, see thexf::Mat Image Container Class.

The reVISION platform supports both live and file input-output (I/O) modes. For more details, see the reVISION Getting Started Guide.
  • 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.
    1. Processing system (PS) reads the image frame from the SD Card and stores it in the DRAM.
    2. ThexfOpenCVkernel reads the image from the DRAM, processes it and stores the output back in the DRAM memory.
    3. 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.
    1. Video capture IPs receive a frame and store it in the DRAM.
    2. ThexfOpenCVkernel fetches the image from the DRAM, processes the image, and stores the output in the DRAM.
    3. 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:

Figure:xfOpenCV Kernel on the reVISION Platform



Note:For more information on the PS-PL interfaces and PL-DDR interfaces, see the Zynq UltraScale+ Device Technical Reference Manual(UG1085).

xfOpenCV Library Contents

The following table lists the contents of thexfOpenCVlibrary.

Table 1.xfOpenCV Library Contents
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 themathfunctions.
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.