Getting Started with SDSoC
This chapter provides the information you need to bring up your design using thexfOpenCVlibrary functions.
Prerequisites
- Download and install the SDx development environment according to the directions provided inSDSoC Development Environment Release Notes, Installation, and Licensing Guide. Before launching the SDx development environment on Linux, set the
$SYSROOT
environment variable to point to the Linux root file system if using terminal to build project, delivered with the reVISION platform. For example:export SYSROOT =
/zcu104_rv_ss/sw/a53_linux/a53_linux/sysroot/aarch64-xilinx-xilinx - Download theZynq® UltraScale+™ MPSoCEmbedded Vision Platform zip file and extract its contents. Create the SDx development environment workspace in thezcu104_rv_ssfolder of the extracted design file hierarchy. For more details, see thereVISION Getting Started Guide.
- Set up the ZCU104 evaluation board. For more details, see thereVISION Getting Started Guide.
- Download thexfOpenCVlibrary. This library is made available through github. Run the following
git clone
command to clone thexfOpenCVrepository to your local disk:git clone https://github.com/Xilinx/xfopencv.git
Migrating HLS Video Library to xfOpenCV
The HLS video library will soon be deprecated .All the functions and most of the infrastructure available in HLS video library are now available inxfOpenCVwith their names changed and some modifications. These HLS video library functions ported toxfOpenCVsupport SDSoc build flow also.
This section provides the details on using the C++ video processing functions and the infrastructure present in HLS video library.
Infrastructure Functions and Classes
All the functions imported from HLS video library now take xf::Mat (in sync withxfOpenCVlibrary) to represent image data instead of hls::Mat. The main difference between these two is that the hls::Mat uses hls::stream to store the data whereas xf::Mat uses a pointer. Therefore, hls:: Mat cannot be exactly replaced with xf::Mat for migrating.
Below table summarizes the differences between member functions of hls::Mat to xf::Mat.
Member Function | hls::Mat (HLS Video lib) | Xf::Mat (xfOpenCV lib) |
---|---|---|
channels() | Returns the number of channels | Returns the number of channels |
type() | Returns the enum value of pixel type | Returns the enum value of pixel type |
depth() | Returns the enum value of pixel type | Returns the depth of pixel including channels |
read() | Readout a value and return it as a scalar from stream | Readout a value from a given location and return it as a packed (for multi-pixel/clock) value. |
operator >> | Similar to read() | Not available inxfOpenCV |
operator << | Similar to write() | Not available inxfOpenCV |
Write() | Write a scalar value into the stream | Writes a packed (for multi-pixel/clock) value into the given location.. |
Infrastructure files available in HLS Video Library hls_video_core.h, hls_video_mem.h, hls_video_types.h are moved to xf_video_core.h, xf_video_mem.h, xf_video_types.h inxfOpenCVLibrary and hls_video_imgbase.h is deprecated. Code inside these files unchanged except that these are now under xf::namespace.
Classes
- Memory Window Buffer
- hls::window is now xf::window. No change in the implementation, except the namespace change. This is located in “xf_video_mem.h” file.
- Memory Line Buffer
- hls::LineBuffer is now xf::LineBuffer. No difference between the two, except xf::LineBuffer has extra template arguments for inferring different types of RAM structures, for the storage structure used. Default storage type is “RAM_S2P_BRAM” with RESHAPE_FACTOR=1. Complete description can be found here xf::LineBuffer. This is located in xf_video_mem.hfile.
Funtions
- OpenCV interface functions
- These functions covert image data of OpenCV Mat format to/from HLS AXI types. HLS Video Library had 14 interface functions, out of which, two functions are available in xfOpenCV Library: cvMat2AXIvideo and AXIvideo2cvMat located in “xf_axi.h” file. The rest are all deprecated.
- AXI4-Stream I/O Functions
- The I/O functions which convert hls::Mat to/from AXI4-Stream compatible data type (hls::stream) are hls::AXIvideo2Mat, hls::Mat2AXIvideo. These functions are now deprecated and added 2 new functions xf::AXIvideo2xfMat and xf:: xfMat2AXIvideo to facilitate the xf::Mat to/from conversion. To use these functions, the header file "xf_infra.h" must be included.
xf::window
A template class to represent the 2D window buffer. It has three parameters to specify the number of rows, columns in window buffer and the pixel data type.
Class definition
template class Window { public: Window() /* Window main APIs */ void shift_pixels_left(); void shift_pixels_right(); void shift_pixels_up(); void shift_pixels_down(); void insert_pixel(T value, int row, int col); void insert_row(T value[COLS], int row); void insert_top_row(T value[COLS]); void insert_bottom_row(T value[COLS]); void insert_col(T value[ROWS], int col); void insert_left_col(T value[ROWS]); void insert_right_col(T value[ROWS]); T& getval(int row, int col); T& operator ()(int row, int col); T val[ROWS][COLS]; #ifdef __DEBUG__ void restore_val(); void window_print(); T val_t[ROWS][COLS]; #endif };
Parameter Descriptions
The following table lists the xf::Window class members and their descriptions.
Parameter | Description |
---|---|
Val | 2-D array to hold the contents of buffer. |
Member Function Description
Function | Description |
---|---|
shift_pixels_left() | Shift the window left, that moves all stored data within the window right, leave the leftmost column (col = COLS-1) for inserting new data. |
shift_pixels_right() | Shift the window right, that moves all stored data within the window left, leave the rightmost column (col = 0) for inserting new data. |
shift_pixels_up() | Shift the window up, that moves all stored data within the window down, leave the top row (row = ROWS-1) for inserting new data. |
shift_pixels_down() | Shift the window down, that moves all stored data within the window up, leave the bottom row (row = 0) for inserting new data. |
insert_pixel(T value, int row, int col) | Insert a new element value at location (row, column) of the window. |
insert_row(T value[COLS], int row) | Inserts a set of values in any row of the window. |
insert_top_row(T value[COLS]) | Inserts a set of values in the top row = 0 of the window. |
insert_bottom_row(T value[COLS]) | Inserts a set of values in the bottom row = ROWS-1 of the window. |
insert_col(T value[ROWS], int col) | Inserts a set of values in any column of the window. |
insert_left_col(T value[ROWS]) | Inserts a set of values in left column = 0 of the window. |
insert_right_col(T value[ROWS]) | Inserts a set of values in right column = COLS-1 of the window. |
T& getval(int row, int col) | Returns the data value in the window at position (row,column). |
T& operator ()(int row, int col) | Returns the data value in the window at position (row,column). |
restore_val() | Restore the contents of window buffer to another array. |
window_print() | Print all the data present in window buffer onto console. |
Template Parameter Description
Parameter | Description |
---|---|
ROWS | Number of rows in the window buffer. |
COLS | Number of columns in the window buffer. |
T | Data type of pixel in the window buffer. |
Window kernel;
xf::LineBuffer
A template class to represent 2D line buffer. It has three parameters to specify the number of rows, columns in window buffer and the pixel data type.
Class definition
template class LineBuffer { public: LineBuffer() /* LineBuffer main APIs */ /* LineBuffer main APIs */ void shift_pixels_up(int col); void shift_pixels_down(int col); void insert_bottom_row(T value, int col); void insert_top_row(T value, int col); void get_col(T value[ROWS], int col); T& getval(int row, int col); T& operator ()(int row, int col); /* Back compatible APIs */ void shift_up(int col); void shift_down(int col); void insert_bottom(T value, int col); void insert_top(T value, int col); T val[ROWS][COLS]; #ifdef __DEBUG__ void restore_val(); void linebuffer_print(int col); T val_t[ROWS][COLS]; #endif };
Parameter Descriptions
The following table lists the xf::LineBuffer class members and their descriptions.
Parameter | Description |
---|---|
Val | 2-D array to hold the contents of line buffer. |
Member Functions Description
Function | Description |
---|---|
shift_pixels_up(int col) | Line buffer contents Shift up, new values will be placed in the bottom row=ROWS-1. |
shift_pixels_down(int col) | Line buffer contents Shift down, new values will be placed in the top row=0. |
insert_bottom_row(T value, int col) | Inserts a new value in bottom row= ROWS-1 of the line buffer. |
insert_top_row(T value, int col) | Inserts a new value in top row=0 of the line buffer. |
get_col(T value[ROWS], int col) | Get a column value of the line buffer. |
T& getval(int row, int col) | Returns the data value in the line buffer at position (row, column). |
T& operator ()(int row, int col); | Returns the data value in the line buffer at position (row, column). |
Template Parameter Description
Parameter | Description |
---|---|
ROWS | Number of rows in line buffer. |
COLS | Number of columns in line buffer. |
T | Data type of pixel in line buffer. |
MEM_TYPE | Type of storage element. It takes one of the following enumerated values: RAM_1P_BRAM, RAM_1P_URAM, RAM_2P_BRAM, RAM_2P_URAM, RAM_S2P_BRAM, RAM_S2P_URAM, RAM_T2P_BRAM, RAM_T2P_URAM. |
RESHAPE_FACTOR | Specifies the amount to divide an array. |
LineBuffer<3, 1920, XF_8UC3, RAM_S2P_URAM,1> buff;
Video Processing Functions
The following table summarizes the video processing functions ported from HLS Video Library intoxfOpenCVLibrary along with the API modifications.
Functions | HLS Video Library -API | xfOpenCV Library-API |
---|---|---|
addS |
|
|
AddWeighted |
|
|
Cmp |
|
|
CmpS |
|
|
Max |
|
|
MaxS |
|
|
Min |
|
|
MinS |
|
|
PaintMask |
|
|
Reduce |
|
|
Zero |
|
|
Sum |
|
|
SubS |
|
|
SubRS |
|
|
Set |
|
|
Absdiff |
|
|
And |
|
|
Dilate |
|
|
Duplicate |
|
|
EqualizeHist |
|
|
erode |
|
|
FASTX |
|
|
Filter2D |
|
|
GaussianBlur |
|
|
Harris |
|
|
CornerHarris |
|
|
HoughLines2 |
|
|
Integral |
|
|
Merge |
|
|
MinMaxLoc |
|
|
Mul |
|
|
Not |
|
|
Range |
|
|
Resize |
|
|
sobel |
|
|
split |
|
|
Threshold |
|
|
Scale |
|
|
InitUndistortRectifyMapInverse |
|
|
Avg, mean, AvgStddev |
|
|
CvtColor |
|
Color Conversion |
Using the xfOpenCV Library
This section describes using thexfOpenCVlibrary in the SDx development environment.
includefolder constitutes all the necessary components to build a Computer Vision or Image Processing pipeline using the library. The folderscommonandcorecontain the infrastructure that the library functions need for basic functions, Mat class, and macros. The library functions are categorized into three folders,features,videoandimgprocbased on the operation they perform. The names of the folders are self-explanatory.
To work with the library functions, you need to include the path to the The xfOpenCV library is structured as shown in the following table. Theincludefolder in the SDx project. You can include relevant header files for the library functions you will be working with after you source theincludefolder’s path to the compiler. For example, if you would like to work with Harris Corner Detector and Bilateral Filter, you must use the following lines in the host code:
#include “features/xf_harris.hpp” //for Harris Corner Detector #include “imgproc/xf_bilateral_filter.hpp” //for Bilateral Filter #include “video/xf_kalmanfilter.hpp”
After the headers are included, you can work with the library functions as described in thexfOpenCV Library API Referenceusing the examples in theexamplesfolder as reference.
The following table gives the name of the header file, including the folder name, which contains the library function.
Function Name | File Path in theincludefolder |
---|---|
xf::accumulate | imgproc/xf_accumulate_image.hpp |
xf::accumulateSquare | imgproc/xf_accumulate_squared.hpp |
xf::accumulateWeighted | imgproc/xf_accumulate_weighted.hpp |
The xfOpenCV library is structured as shown in the following table.xf::absdiff, xf::add, xf::subtract, xf::bitwise_and, xf::bitwise_or, xf::bitwise_not, xf::bitwise_xor,xf::multiply ,xf::Max, xf::Min, xf::compare, xf::zero, xf::addS, xf::SubS, xf::SubRS ,xf::compareS, xf::MaxS, xf::MinS, xf::set | core/xf_arithm.hpp |
xf::addWeighted | imgproc/xf_add_weighted.hpp |
xf::bilateralFilter | imgproc/xf_histogram.hpp |
xf::boxFilter | imgproc/xf_box_filter.hpp |
xf::boundingbox | imgproc/xf_boundingbox.hpp |
xf::Canny | imgproc/xf_canny.hpp |
xf::Colordetect | imgproc/xf_colorthresholding.hpp, imgproc/xf_bgr2hsv.hpp, imgproc/xf_erosion.hpp, imgproc/xf_dilation.hpp |
xf::merge | imgproc/xf_channel_combine.hpp |
xf::extractChannel | imgproc/xf_channel_extract.hpp |
xf::convertTo | imgproc/xf_convert_bitdepth.hpp |
xf::crop | imgproc/xf_crop.hpp |
xf::filter2D | imgproc/xf_custom_convolution.hpp |
xf::nv122iyuv, xf::nv122rgba, xf::nv122yuv4, xf::nv212iyuv, xf::nv212rgba, xf::nv212yuv4, xf::rgba2yuv4, xf::rgba2iyuv, xf::rgba2nv12, xf::rgba2nv21, xf::uyvy2iyuv, xf::uyvy2nv12, xf::uyvy2rgba, xf::yuyv2iyuv, xf::yuyv2nv12, xf::yuyv2rgba,xf::rgb2iyuv,xf::rgb2nv12,xf::rgb2nv21,xf::rgb2yuv4,xf::rgb2uyvy,xf::rgb2yuyv,xf::rgb2bgr,xf::bgr2uyvy,xf::bgr2yuyv,xf::bgr2rgb,xf::bgr2nv12,xf::bgr2nv21,xf::iyuv2nv12,xf::iyuv2rgba,xf::iyuv2rgb,xf::iyuv2yuv4,xf::nv122uyvy,xf::nv122yuyv,xf::nv122nv21,xf::nv212rgb,xf::nv212bgr,xf::nv212uyvy,xf::nv212yuyv,xf::nv212nv12,xf::uyvy2rgb,xf::uyvy2bgr,xf::uyvy2yuyv,xf::yuyv2rgb,xf::yuyv2bgr,xf::yuyv2uyvy,xf::rgb2gray,xf::bgr2gray,xf::gray2rgb,xf::gray2bgr,xf::rgb2xyz,xf::bgr2xyz... | imgproc/xf_cvt_color.hpp |
xf::dilate | imgproc/xf_dilation.hpp |
xf::demosaicing | imgproc/xf_demosaicing.hpp |
xf::erode | imgproc/xf_erosion.hpp |
xf::fast | features/xf_fast.hpp |
xf::GaussianBlur | imgproc/xf_gaussian_filter.hpp |
xf::cornerHarris | features/xf_harris.hpp |
xf::calcHist | imgproc/xf_histogram.hpp |
xf::equalizeHist | imgproc/xf_hist_equalize.hpp |
xf::HOGDescriptor | imgproc/xf_hog_descriptor.hpp |
xf::Houghlines | imgproc/xf_houghlines.hpp |
xf::inRange | imgproc/xf_inrange.hpp |
xf::integralImage | imgproc/xf_integral_image.hpp |
xf::densePyrOpticalFlow | video/xf_pyr_dense_optical_flow.hpp |
xf::DenseNonPyrLKOpticalFlow | video/xf_dense_npyr_optical_flow.hpp |
xf::LUT | imgproc/xf_lut.hpp |
xf::KalmanFilter | video/xf_kalmanfilter.hpp |
xf::magnitude | core/xf_magnitude.hpp |
xf::MeanShift | imgproc/xf_mean_shift.hpp |
xf::meanStdDev | core/xf_mean_stddev.hpp |
xf::medianBlur | imgproc/xf_median_blur.hpp |
xf::minMaxLoc | core/xf_min_max_loc.hpp |
xf::OtsuThreshold | imgproc/xf_otsuthreshold.hpp |
xf::phase | core/xf_phase.hpp |
xf::paintmask | imgproc/xf_paintmask.hpp |
xf::pyrDown | imgproc/xf_pyr_down.hpp |
xf::pyrUp | imgproc/xf_pyr_up.hpp |
xf::reduce | imgrpoc/xf_reduce.hpp |
xf::remap | imgproc/xf_remap.hpp |
xf::resize | imgproc/xf_resize.hpp |
xf::scale | imgproc/xf_scale.hpp |
xf::Scharr | imgproc/xf_scharr.hpp |
xf::SemiGlobalBM | imgproc/xf_sgbm.hpp |
xf::Sobel | imgproc/xf_sobel.hpp |
xf::StereoPipeline | imgproc/xf_stereo_pipeline.hpp |
xf::sum | imgproc/xf_sum.hpp |
xf::StereoBM | imgproc/xf_stereoBM.hpp |
xf::SVM | imgproc/xf_svm.hpp |
xf::Threshold | imgproc/xf_threshold.hpp |
xf::warpTransform | imgproc/xf_warp_transform.hpp |
The different ways to use the xfOpenCV library examples are listed below:
Downloading and Using xfOpenCV Libraries from SDx GUI
You can downloadxfOpenCVdirectly from SDx GUI. To build a project using the example makefiles on the Linux platform:
- From SDx IDE, clickXilinxand selectSDx Libraries.
- ClickDownloadnext to theXilinx xfOpenCV Library.
Figure:SDx Libraries
The library is downloaded into/Xilinx/SDx/2019.1/xfopencv . After the library is downloaded, the entire set of examples in the library are available in the list of templates while creating a new project.Note:The library can be added to any project from the IDE menu options. - To add a library to a project, from SDx IDE, clickXilinxand selectSDx Libraries.
- SelectXilinx xfOpenCV Libraryand clickAdd to project. The dropdown menu consists of options of which project the libraries need to be included to.
All the headers as part of theinclude/folder inxfOpenCVlibrary would be copied into the local project directory as
Building a Project Using the Example Makefiles on Linux
Use the following steps to build a project using the example makefiles on the Linux platform:
- Open a terminal.
- When building for revision platform, set the environment variable SYSROOT to <the path to platform folder>/sw/a53_linux/a53_linux/sysroot/aarch64-xilinx-linux.
- Change the platform variable to point to the downloaded platform folder in makefile. Ensure that the folder name of the downloaded platform is unchanged.
- When building for revision platform , change IDIRS and LDIRS variables in the Makefile as follows:
IDIRS = -I. -I${SYSROOT}/usr/include -I ../../include LDIRS = --sysroot=${SYSROOT} -L=/lib -L=/usr/lib -Wl,-rpath-link=${SYSROOT}/lib,-rpath-link=${SYSROOT}/usr/lib
- Change the directory to the location where you want to build the example.
cd
- When building for revision platform , add
#include"opencv2/imgcodecs/imgcodecs.hpp"
inxf_headers.hfile ,both in if and else part. - Set the environment variables to run SDx development environment.
- For c shell:
source
/settings.csh - For bash shell:
source
/settings.sh
- For c shell:
- Type the
make
command in the terminal. Thesd_cardfolder is created and can be found in thefolder.
Using reVISION Samples on the reVISION Platform
Use the following steps to run a unit test for bilateral filter on zcu104_rv_ss:
- Launch the SDx development environment using the desktop icon or theStartmenu.
TheWorkspace Launcherdialog appears.
- ClickBrowseto enter a workspace folder used to store your projects (you can use workspace folders to organize your work), then clickOKto dismiss theWorkspace Launcherdialog.
Note:Before launching the SDx IDE on Linux, ensure that you use the same shell that you have used to set the
$SYSROOT
environment variable. This is usually the file path to the Linux root file system.The SDx development environment window opens with theWelcometab visible when you create a new workspace. TheWelcometab can be closed by clicking theXicon or minimized if you do not wish to use it.
- Select
TheNew Projectdialog box opens.
from the SDx development environment menu bar. - Specify the name of the project. For exampleBilateral.
- ClickNext.
The theChoose Hardware Platformpage appears.
- From theChoose Hardware Platformpage, click theAdd Custom Platformbutton.
- Browse to the directory where you extracted the reVISION platform files. Ensure that you select thezcu104_rv_ssfolder.
- From theChoose Hardware Platformpage, selectzcu104_rv_ss (custom).
- ClickNext.
TheTemplatespage appears, containing source code examples for the selected platform.
- From the list of application templates, selectbilateral - File I/Oand clickFinish.
- add
#include"opencv2/imgcodecs/imgcodecs.hpp"
inxf_headers.hfile present underproject/src/examples/bilateral/,both in if and else part. - Click theActive build configurationsdrop-down from theSDx Project Settingswindow, to select the active configuration or create a build configuration.
The standard build configurations are Debug and Release. To get the best runtime performance, switch to use theReleasebuild configuration as it uses a higher compiler optimization setting than the Debug build configuration.
Figure:SDx Project Settings - Active Build Configuration
- Set theData motion network clock frequency (MHz)to the required frequency, on theSDx Project Settingspage.
- Right-click the project and selectBuild Projector press Ctrl+B keys to build the project, in theProject Explorerview.
- Copy the contents of the newly createdsd_cardfolder to the SD card. Thesd_cardfolder contains all the files required to run designs on the
ZCU104
board. - Insert the SD card in the
ZCU104
board card slot and switch it ON.Note:A serial port emulator (Teraterm/ minicom) is required to interface the user commands to the board. - Upon successful boot, run the following command in the Teraterm terminal (serial port emulator.)
#cd /media/card #remount
- Run the.elffile for the respective functions.
For more information, see theUsing the xfOpenCV Library Functions on Hardware.
Using the xfOpenCV Library on a non-reVISION Platform
This section describes using thexfOpenCVlibrary on a non-reVISION platform, in theSDx™development environment. The examples in xfOpenCV requireOpenCVlibraries for successful compilation. As non-reVISION platform may or may not contain opencv libs, as a perquisites it is required to install/compile opencv libraries(with compatible libjpeg.so).
Use the following steps to import thexfOpenCVlibrary into aSDxproject and execute it on a custom platform:
Launch theSDxdevelopment environment using the desktop icon or theStartmenu.
TheWorkspace Launcherdialog appears.
ClickBrowseto enter a workspace folder used to store your projects (you can use workspace folders to organize your work), then clickOKto dismiss theWorkspace Launcherdialog.
TheSDxdevelopment environment window opens with theWelcometab visible when you create a new workspace. TheWelcometab can be closed by clicking theXicon or minimized if you do not wish to use it.
SelectSDxdevelopment environment menu bar.
from theTheNew Projectdialog box opens.
- Specify the name of the project. For exampleTest.
ClickNext.
The theChoose Hardware Platformpage appears.
- From theChoose Hardware Platformpage, select a suitable platform. For example,zcu102.
ClickNext.
TheChoose Software Platform and Target CPUpage appears.
- From theChoose Software Platform and Target CPUpage, select an appropriate software platform and the target CPU. For example, selectA9from theCPUdropdown list for ZC702 and ZC706 reVISION platforms.
- ClickNext. TheTemplatespage appears, containing source code examples for the selected platform.
From the list of application templates, selectEmpty Applicationand clickFinish.
TheNew Projectdialog box closes. A new project with the specified configuration is created. TheSDx Project Settingsview appears. Notice the progress bar in the lower right border of the view, Wait for a few moments for theC/C++ Indexerto finish.
-
The standard build configurations are Debug and Release. To get the best run-time performance, switch to use the Releasebuild configuration as it uses a higher compiler optimization setting than the Debug build configuration.
Figure:SDx Project Settings - Active Build Configuration
- Set theData motion network clock frequency (MHz)to the required frequency, on theSDx Project Settingspage.
- Select theGenerate bitstreamandGenerate SD card imagecheck boxes.
- Right-click on the newly created project in theProject Explorerview.
From the context menu that appears, selectC/C++ Build Settings.
TheProperties for
dialog box appears. - Click theTool Settingstab.
- Expand the tree.
Click the
icon to add the"
\include" and"\include" folder locations to theInclude Pathslist.Note:The OpenCVlibrary is not provided by Xilinx for custom platforms. You are required to provide the library. Use the reVISION platform in order to use the OpenCVlibrary provided by Xilinx.Figure:SDS++ Compiler Settings
- In the same page, under , specify "-hls-target 1" in the Software Platform Inferred Flags.
- ClickApply.
- Expand the tree.
- Click the
icon and add the following libraries to theLibraries(-l)list. These libraries are required byOpenCV.
- opencv_core
- opencv_imgproc
- opencv_imgcodecs
- opencv_features2d
- opencv_calib3d
- opencv_flann
- opencv_video
- opencv_videoio
Click the
icon and add
/lib folder location to theLibraries search path (-L)list.Note:The OpenCV library is not provided by Xilinx for custom platforms. You are required to provide the library. Use the reVISION platform in order to use the OpenCV library provided by Xilinx.Figure:SDS++ Linker Settings
- ClickApplyto save the configuration.
- ClickOKto close theProperties for
dialog box. - Expand the newly created project tree in theProject Explorerview.
- Right-click thesrcfolder and selectImport. TheImportdialog box appears.
- SelectFile Systemand clickNext.
- ClickBrowseto navigate to the
/examples folder location. Select the folder that corresponds to the library that you desire to import. For example,accumulate.
Figure:Import Library Example Source Files
- Right-click the library function in theProject Explorerview and selectToggle HW/SWto move the function to the hardware.
Figure:Moving a Library Function to the Hardware
Right-click the project and selectBuild Projector press Ctrl+B keys to build the project, in theProject Explorerview.
The build process may take anytime between few minutes to several hours, depending on the power of the host machine and the complexity of the design. By far, the most time is spent processing the routines that have been tagged for realization in hardware.
- Copy the contents of the newly created.\
\ folder to the SD card. Thesd_cardfolder contains all the files required to run designs on a board.\Release\sd_card Insert the SD card in the board card slot and switch it ON.
Note:A serial port emulator (Teraterm/ minicom) is required to interface the user commands to the board.- Upon successful boot, navigate to the./mntfolder and run the following command at the prompt:
#cd /mnt
Note:It is assumed that the OpenCV libraries are a port of the root filesystem. If not, add the location of OpenCV libraries toLD_LIBRARY_PATH
using the$ export LD_LIBRARY_PATH=
command./lib - Run the.elfexecutable file. For more information, see theUsing the xfOpenCV Library Functions on Hardware.
Changing the Hardware Kernel Configuration
- Update the
xfOpenCV git folder>/xfOpenCV/examples//xf_config_params.hfile. - Update the makefile along with thexf_config_params.hfile:
- Find the line with the function name in the makefile. For bilateral filter, the line in the makefile will be
xf::BilateralFilter<3,1,0,1080,1920,1>
. - Update the template parameters in the makefile to reflect changes made in thexf_config_params.hfile. For more details, see thexfOpenCV Library API Reference.
- Find the line with the function name in the makefile. For bilateral filter, the line in the makefile will be
Using the xfOpenCV Library Functions on Hardware
The following table lists thexfOpenCVlibrary functions and the command to run the respective examples on hardware. It is assumed that your design is completely built and the board has booted up correctly.
Example | Function Name | Usage on Hardware |
---|---|---|
accumulate | xf::accumulate | ./ |
accumulatesquared | xf::accumulateSquare | ./ |
accumulateweighted | xf::accumulateWeighted | ./ |
addS | xf::addS | ./ |
arithm | xf::absdiff, xf::add, xf::subtract, xf::bitwise_and, xf::bitwise_or, xf::bitwise_not, xf::bitwise_xor | ./ |
addweighted | xf::addWeighted | ./ |
Bilateralfilter | xf::bilateralFilter | ./ |
Boxfilter | xf::boxFilter | ./ |
Boundingbox | xf::boundingbox | ./ |
Canny | xf::Canny | ./ |
channelcombine | xf::merge | ./ |
Channelextract | xf::extractChannel | ./ |
Colordetect | xf::bgr2hsv, xf::colorthresholding, xf:: erode, and xf:: dilate | ./ |
compare | xf::compare | ./ |
compareS | xf::compareS | ./ |
Convertbitdepth | xf::convertTo | ./ |
Cornertracker | xf::cornerTracker | ./exe |
crop | xf::crop | ./ |
Customconv | xf::filter2D | ./ |
cvtcolor IYUV2NV12 | xf::iyuv2nv12 | ./ |
cvtcolor IYUV2RGBA | xf::iyuv2rgba | ./ |
cvtcolor IYUV2YUV4 | xf::iyuv2yuv4 | ./ |
cvtcolor NV122IYUV | xf::nv122iyuv | ./ |
cvtcolor NV122RGBA | xf::nv122rgba | ./ |
cvtcolor NV122YUV4 | xf::nv122yuv4 | ./ |
cvtcolor NV212IYUV | xf::nv212iyuv | ./ |
cvtcolor NV212RGBA | xf::nv212rgba | ./ |
cvtcolor NV212YUV4 | xf::nv212yuv4 | ./ |
cvtcolor RGBA2YUV4 | xf::rgba2yuv4 | ./ |
cvtcolor RGBA2IYUV | xf::rgba2iyuv | ./ |
cvtcolor RGBA2NV12 | xf::rgba2nv12 | ./ |
cvtcolor RGBA2NV21 | xf::rgba2nv21 | ./ |
cvtcolor UYVY2IYUV | xf::uyvy2iyuv | ./ |
cvtcolor UYVY2NV12 | xf::uyvy2nv12 | ./ |
cvtcolor UYVY2RGBA | xf::uyvy2rgba | ./ |
cvtcolor YUYV2IYUV | xf::yuyv2iyuv | ./ |
cvtcolor YUYV2NV12 | xf::yuyv2nv12 | ./ |
cvtcolor YUYV2RGBA | xf::yuyv2rgba | ./ |
Demosaicing | xf::demosaicing | ./ |
Difference of Gaussian | xf:: GaussianBlur, xf:: duplicateMat, xf:: delayMat, and xf::subtract | ./ |
Dilation | xf::dilate | ./ |
Erosion | xf::erode | ./ |
Fast | xf::fast | ./ |
Gaussianfilter | xf::GaussianBlur | ./ |
Harris | xf::cornerHarris | ./ |
Histogram | xf::calcHist | ./ |
Histequialize | xf::equalizeHist | ./ |
Hog | xf::HOGDescriptor | ./ |
Houghlines | xf::HoughLines | ./ |
inRange | xf::inRange | ./ |
Integralimg | xf::integralImage | ./ |
Lkdensepyrof | xf::densePyrOpticalFlow | ./ |
Lknpyroflow | xf::DenseNonPyrLKOpticalFlow | ./ |
Lut | xf::LUT | ./ |
Kalman Filter | xf::KalmanFilter | ./ |
Magnitude | xf::magnitude | ./ |
Max | xf::Max | ./ |
MaxS | xf::MaxS | ./ |
meanshifttracking | xf::MeanShift | ./ |
meanstddev | xf::meanStdDev | ./ |
medianblur | xf::medianBlur | ./ |
Min | xf::Min | ./ |
MinS | xf::MinS | ./ |
Minmaxloc | xf::minMaxLoc | ./ |
otsuthreshold | xf::OtsuThreshold | ./ |
paintmask | xf::paintmask | ./ |
Phase | xf::phase | ./ |
Pyrdown | xf::pyrDown | ./ |
Pyrup | xf::pyrUp | ./ |
reduce | xf::reduce | ./ |
remap | xf::remap | ./ |
Resize | xf::resize | ./ |
scale | xf::scale | ./ |
scharrfilter | xf::Scharr | ./ |
set | xf::set | ./ |
SemiGlobalBM | xf::SemiGlobalBM | ./ |
sobelfilter | xf::Sobel | ./ |
stereopipeline | xf::StereoPipeline | ./ |
stereolbm | xf::StereoBM | ./ |
subRS | xf::SubRS | ./ |
subS | xf::SubS | ./ |
sum | xf::sum | ./ |
Svm | xf::SVM | ./ |
threshold | xf::Threshold | ./ |
warptransform | xf::warpTransform | ./ |
zero | xf::zero | ./ |