Skip to content

Commit

Permalink
Merge pull request #26 from denolf/master
Browse files Browse the repository at this point in the history
2018.3 release
  • Loading branch information
jackl-xilinx authored Oct 4, 2019
2 parents b7e0c4d + fd75a0b commit f270218
Show file tree
Hide file tree
Showing 210 changed files with 6,509 additions and 1,344 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "frameworks/cmakeModules/cmakeModulesXilinx"]
path = frameworks/cmakeModules/cmakeModulesXilinx
url = https://github.com/Xilinx/cmakeModules
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All PYNQ releases ship with the popular [OpenCV](https://opencv.org/) library pre-installed. The PYNQ computer vision overlays enable accelerating OpenCV components in Programmable Logic (PL). These overlays expose a subset Xilinx' [xfOpenCV](https://github.com/Xilinx/xfopencv) library (a part of Xilinx' [reVISION solution](https://www.xilinx.com/products/design-tools/embedded-vision-zone.html)) at the Python level, combined with the support for HDMI input/output (Pynq-Z1 and Pynq-Z2 only). Webcam, stream or file based input/output remains available through the pre-installed SW OpenCV (on all Pynq boards).

Currently this package is compatible with [PYNQ image v2.3](http://www.pynq.io/board).
Currently this package is compatible with [PYNQ image v2.4](http://www.pynq.io/board).

![](./block_diagram.png)

Expand All @@ -29,7 +29,7 @@ After the setup, new Jupyter notebooks will be added under the pynqOpenCV folder

When after profiling, the critical OpenCV modules in an application are identified, the generation of a tailored overlay is easily done by specifying those modules as a list in a CMake project file. After that, building the tailored overlay only requires running cmake to generate the Makefiles followed by make to build the overlay.

For detailed instructions: [Building xfOpenCV Overlays for Pynq: CMake based sds++ cross-compilation](overlays/README.md). Currently, this only supports building on the Ultra96 with 2018.2 Xilinx tools.
For detailed instructions: [Building xfOpenCV Overlays for Pynq: CMake based sds++ cross-compilation](overlays/README.md). Currently, this only supports building on the Ultra96 with 2018.3 Xilinx tools.

## License

Expand Down
27 changes: 19 additions & 8 deletions applicationCode/unitTests/testC++/buildUnitTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,27 @@
from distutils.dir_util import mkpath
import shutil

toolchain_file = "../../../../../frameworks/cmakeModules/toolchain_sdx2018.2.cmake"
toolchain_file = "../../../../../frameworks/cmakeModules/cmakeModulesXilinx/toolchain_sds.cmake"
arch = "arm64"
clockID = "3"
platform = "/platforms/Ultra96/bare/2018.2/ultra"
platform = "/group/xrlabs/projects/image_processing/platforms/Ultra96/ultra_v2.4/2018.3/ultra"
usePL = "ON"
noBitstream = "OFF"
noSDCardImage = "ON"
unitTestFileDir = "unitTestFiles"
buildDir = "build"
unitTestFileDir = "unitTestFilesUltra96"
buildDir = "buildUltra96"

#clockID = "2"
#platform = "/group/xrlabs/tools/reVISION/platforms/zcu102_rv_ss/2018.3/zcu102_rv_ss"
#platform = "/group/xrlabs/tools/reVISION/platforms/zcu104_rv_min_2019.1"
#usePL = "ON"
#noBitstream = "OFF"
#noSDCardImage = "ON"
#unitTestFileDir = "unitTestFilesZCU102"
#buildDir = "buildzcu102"

#unitTestFileDir = "unitTestFilesCSIM"
#buildDir = "build2019.1"

#*****************************************************************************
# Create a conversion .bif file
Expand Down Expand Up @@ -87,15 +98,15 @@ def buildUnitTest(component):
#run cmake here
os.system("cmake .. -DCMAKE_TOOLCHAIN_FILE="+toolchain_file+" -DSDxArch="+arch+" -DSDxClockID="+clockID+" -DSDxPlatform="+platform+" -DusePL="+usePL+" -DnoBitstream="+noBitstream+" -DnoSDCardImage="+noSDCardImage+" >& cmake.log")
if '-- Build files have been written to' in open('cmake.log').read():
print("\t CMake OK", end='')
print("\t CMake OK", end='', flush=True)
else:
print("\t CMake FAIL", end='')
print("\t CMake FAIL", end='', flush=True)
#run make
os.system("make "+target+" >& make.log")
if '[100%] Built target' in open('make.log').read():
print("\t build OK")
print("\t build OK", flush=True)
else:
print("\t build FAIL")
print("\t build FAIL", flush=True)
os.chdir("..")
return
#convert bitstream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
cmake_minimum_required(VERSION 2.8)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../frameworks/cmakeModules/cmakeModulesXilinx ${CMAKE_CURRENT_SOURCE_DIR}/../../../../frameworks/cmakeModules)
include(rulesForSDxXfOpenCV)
include(rulesForXfOpenCV)
SET(componentName absdiff)

createXfOpenCVUnitTestPL("../../../.." ${componentName})
createXfOpenCVUnitTestPL("../../../.." ${componentName})
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ int main ( int argc, char** argv )
initializeSingleImageTest(fileName1, src1);
initializeSingleImageTest(fileName2, src2);

cvtColor(src1, gray1, CV_BGR2GRAY, 1);
cvtColor(src2, gray2, CV_BGR2GRAY, 1);
cvtColor(src1, gray1, COLOR_BGR2GRAY, 1);
cvtColor(src2, gray2, COLOR_BGR2GRAY, 1);

if (numberOfIterations > 0) {
HRTimer timer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,12 @@ int main ( int argc, char** argv )
xF::Mat dstHLS(height, width, CV_8UC1);

//convert 3-channel image into 1-channel image
cvtColor(src1, src1HLS, CV_BGR2GRAY, 1);
cvtColor(src2, src2HLS, CV_BGR2GRAY, 1);
cvtColor(src1, src1InY, CV_BGR2GRAY, 1);
cvtColor(src2, src2InY, CV_BGR2GRAY, 1);
cvtColor(src1, src1InY, COLOR_BGR2GRAY, 1);
cvtColor(src2, src2InY, COLOR_BGR2GRAY, 1);
//cvtColor(src1, src1HLS, COLOR_BGR2GRAY, 1);
//cvtColor(src2, src2HLS, COLOR_BGR2GRAY, 1);
src1HLS.copyFromCvMat(src1InY);
src2HLS.copyFromCvMat(src2InY);

// Apply OpenCV reference Absdiff
std::cout << "running golden model" << std::endl;
Expand All @@ -152,7 +154,7 @@ int main ( int argc, char** argv )
int numberOfDifferences = 0;
double errorPerPixel = 0;
imageCompare(dstHLS, dstSW, numberOfDifferences, errorPerPixel, true, false);
std::cout << "number of differences: " << numberOfDifferences << " average L2 error: " << errorPerPixel << std::endl;
std::cout << "number of differences: " << numberOfDifferences << " average L1 error: " << errorPerPixel << std::endl;

//write back images in files
if (writeSWResult)
Expand Down
2 changes: 1 addition & 1 deletion applicationCode/unitTests/testC++/testXfAccumulate/CMakeLists.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
cmake_minimum_required(VERSION 2.8)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../frameworks/cmakeModules/cmakeModulesXilinx ${CMAKE_CURRENT_SOURCE_DIR}/../../../../frameworks/cmakeModules)
include(rulesForSDxXfOpenCV)
include(rulesForXfOpenCV)
SET(componentName accumulate)

createXfOpenCVUnitTestPL("../../../.." ${componentName})
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int main ( int argc, char** argv )
initializeSingleImageTest(fileName, src);

//convert to grayscale
cvtColor(src, gray, CV_BGR2GRAY, 1);
cvtColor(src, gray, COLOR_BGR2GRAY, 1);
Mat dstSW = Mat::zeros(gray.size(), CV_32FC1);

if (numberOfIterations > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int main ( int argc, char** argv )
initializeSingleImageTest(fileName, src);

//convert to grayscale
cvtColor(src, gray, CV_BGR2GRAY, 1);
cvtColor(src, gray, COLOR_BGR2GRAY, 1);
Mat dstSW = Mat::zeros(gray.size(), CV_32FC1);

int width = src.size().width;
Expand All @@ -118,7 +118,7 @@ int main ( int argc, char** argv )
xF::Mat dstHLS(height, width, CV_16UC1); //XF_16UC1

//convert 3-channel image into 1-channel image
cvtColor(src, srcHLS, CV_BGR2GRAY, 1);
cvtColor(src, srcHLS, COLOR_BGR2GRAY, 1);

// Apply OpenCV reference accumulate
std::cout << "running golden model" << std::endl;
Expand Down Expand Up @@ -146,7 +146,7 @@ int main ( int argc, char** argv )
int numberOfDifferences = 0;
double errorPerPixel = 0;
imageCompare(dstHLS, dstSW, numberOfDifferences, errorPerPixel, true, false);
std::cout << "number of differences: " << numberOfDifferences << " average L2 error: " << errorPerPixel << std::endl;
std::cout << "number of differences: " << numberOfDifferences << " average L1 error: " << errorPerPixel << std::endl;

//write back images in files
if (writeSWResult)
Expand Down
2 changes: 1 addition & 1 deletion applicationCode/unitTests/testC++/testXfAccumulateSquare/CMakeLists.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
cmake_minimum_required(VERSION 2.8)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../frameworks/cmakeModules/cmakeModulesXilinx ${CMAKE_CURRENT_SOURCE_DIR}/../../../../frameworks/cmakeModules)
include(rulesForSDxXfOpenCV)
include(rulesForXfOpenCV)
SET(componentName accumulateSquare)

createXfOpenCVUnitTestPL("../../../.." ${componentName})
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int main ( int argc, char** argv )
initializeSingleImageTest(fileName, src);

//convert to grayscale
cvtColor(src, gray, CV_BGR2GRAY, 1);
cvtColor(src, gray, COLOR_BGR2GRAY, 1);
Mat dstSW = Mat::zeros(gray.size(), CV_32FC1);

if (numberOfIterations > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int main ( int argc, char** argv )
initializeSingleImageTest(fileName, src);

//convert to grayscale
cvtColor(src, gray, CV_BGR2GRAY, 1);
cvtColor(src, gray, COLOR_BGR2GRAY, 1);
Mat dstSW = Mat::zeros(gray.size(), CV_32FC1);

int width = src.size().width;
Expand All @@ -118,7 +118,7 @@ int main ( int argc, char** argv )
xF::Mat dstHLS(height, width, CV_16UC1); //XF_16UC1

//convert 3-channel image into 1-channel image
cvtColor(src, srcHLS, CV_BGR2GRAY, 1);
cvtColor(src, srcHLS, COLOR_BGR2GRAY, 1);

// Apply OpenCV reference accumulate
std::cout << "running golden model" << std::endl;
Expand Down Expand Up @@ -146,7 +146,7 @@ int main ( int argc, char** argv )
int numberOfDifferences = 0;
double errorPerPixel = 0;
imageCompare(dstHLS, dstSW, numberOfDifferences, errorPerPixel, true, false);
std::cout << "number of differences: " << numberOfDifferences << " average L2 error: " << errorPerPixel << std::endl;
std::cout << "number of differences: " << numberOfDifferences << " average L1 error: " << errorPerPixel << std::endl;

//write back images in files
if (writeSWResult)
Expand Down
2 changes: 1 addition & 1 deletion applicationCode/unitTests/testC++/testXfAccumulateWeighted/CMakeLists.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
cmake_minimum_required(VERSION 2.8)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../frameworks/cmakeModules/cmakeModulesXilinx ${CMAKE_CURRENT_SOURCE_DIR}/../../../../frameworks/cmakeModules)
include(rulesForSDxXfOpenCV)
include(rulesForXfOpenCV)
SET(componentName accumulateWeighted)

createXfOpenCVUnitTestPL("../../../.." ${componentName})
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ int main ( int argc, char** argv )

/// Declare variables
Mat src, gray;
double alpha=0.2;
double alpha = 0.4;
// Initialize
initializeSingleImageTest(fileName, src);

//convert to grayscale
cvtColor(src, gray, CV_BGR2GRAY, 1);
cvtColor(src, gray, COLOR_BGR2GRAY, 1);
Mat dstSW = Mat::zeros(gray.size(), CV_32FC1);

if (numberOfIterations > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int main ( int argc, char** argv )
initializeSingleImageTest(fileName, src);

//convert to grayscale
cvtColor(src, gray, CV_BGR2GRAY, 1);
cvtColor(src, gray, COLOR_BGR2GRAY, 1);
Mat dstSW = Mat::zeros(gray.size(), CV_32FC1);

int width = src.size().width;
Expand All @@ -118,7 +118,7 @@ int main ( int argc, char** argv )
xF::Mat dstHLS(height, width, CV_16UC1); //XF_16UC1

//convert 3-channel image into 1-channel image
cvtColor(src, srcHLS, CV_BGR2GRAY, 1);
cvtColor(src, srcHLS, COLOR_BGR2GRAY, 1);

// Apply OpenCV reference accumulate
std::cout << "running golden model" << std::endl;
Expand Down Expand Up @@ -146,7 +146,7 @@ int main ( int argc, char** argv )
int numberOfDifferences = 0;
double errorPerPixel = 0;
imageCompare(dstHLS, dstSW, numberOfDifferences, errorPerPixel, true, false);
std::cout << "number of differences: " << numberOfDifferences << " average L2 error: " << errorPerPixel << std::endl;
std::cout << "number of differences: " << numberOfDifferences << " average L1 error: " << errorPerPixel << std::endl;

//write back images in files
if (writeSWResult)
Expand Down
2 changes: 1 addition & 1 deletion applicationCode/unitTests/testC++/testXfAdd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
cmake_minimum_required(VERSION 2.8)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../frameworks/cmakeModules/cmakeModulesXilinx ${CMAKE_CURRENT_SOURCE_DIR}/../../../../frameworks/cmakeModules)
include(rulesForSDxXfOpenCV)
include(rulesForXfOpenCV)
SET(componentName add)

createXfOpenCVUnitTestPL("../../../.." ${componentName})
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ int main ( int argc, char** argv )
initializeSingleImageTest(fileName1, src1);
initializeSingleImageTest(fileName2, src2);
//convert to grayscale
cvtColor(src1, gray1, CV_BGR2GRAY, 1);
cvtColor(src2, gray2, CV_BGR2GRAY, 1);
cvtColor(src1, gray1, COLOR_BGR2GRAY, 1);
cvtColor(src2, gray2, COLOR_BGR2GRAY, 1);

if (numberOfIterations > 0) {
HRTimer timer;
Expand Down
12 changes: 7 additions & 5 deletions applicationCode/unitTests/testC++/testXfAdd/src/testSDxXfAdd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@ int main ( int argc, char** argv )
xF::Mat dstHLS(height, width, CV_8UC1);

//convert 3-channel image into 1-channel image
cvtColor(src1, src1HLS, CV_BGR2GRAY, 1);
cvtColor(src2, src2HLS, CV_BGR2GRAY, 1);
cvtColor(src1, src1InY, CV_BGR2GRAY, 1);
cvtColor(src2, src2InY, CV_BGR2GRAY, 1);
cvtColor(src1, src1InY, COLOR_BGR2GRAY, 1);
cvtColor(src2, src2InY, COLOR_BGR2GRAY, 1);
//cvtColor(src1, src1HLS, COLOR_BGR2GRAY, 1);
//cvtColor(src2, src2HLS, COLOR_BGR2GRAY, 1);
src1HLS.copyFromCvMat(src1InY);
src2HLS.copyFromCvMat(src2InY);

// Apply OpenCV reference subtract
std::cout << "running golden model" << std::endl;
Expand All @@ -152,7 +154,7 @@ int main ( int argc, char** argv )
int numberOfDifferences = 0;
double errorPerPixel = 0;
imageCompare(dstHLS, dstSW, numberOfDifferences, errorPerPixel, true, false);
std::cout << "number of differences: " << numberOfDifferences << " average L2 error: " << errorPerPixel << std::endl;
std::cout << "number of differences: " << numberOfDifferences << " average L1 error: " << errorPerPixel << std::endl;

//write back images in files
if (writeSWResult)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
cmake_minimum_required(VERSION 2.8)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../frameworks/cmakeModules/cmakeModulesXilinx ${CMAKE_CURRENT_SOURCE_DIR}/../../../../frameworks/cmakeModules)
include(rulesForSDxXfOpenCV)
include(rulesForXfOpenCV)
SET(componentName bitwise_and)

createXfOpenCVUnitTestPL("../../../.." ${componentName})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ int main ( int argc, char** argv )
initializeSingleImageTest(fileName1, src1);
initializeSingleImageTest(fileName2, src2);
//convert to grayscale
cvtColor(src1, gray1, CV_BGR2GRAY, 1);
cvtColor(src2, gray2, CV_BGR2GRAY, 1);
cvtColor(src1, gray1, COLOR_BGR2GRAY, 1);
cvtColor(src2, gray2, COLOR_BGR2GRAY, 1);

if (numberOfIterations > 0) {
HRTimer timer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ int main ( int argc, char** argv )
xF::Mat dstHLS(height, width, CV_8UC1);

//convert 3-channel image into 1-channel image
cvtColor(src1, src1HLS, CV_BGR2GRAY, 1);
cvtColor(src2, src2HLS, CV_BGR2GRAY, 1);
cvtColor(src1, src1InY, CV_BGR2GRAY, 1);
cvtColor(src2, src2InY, CV_BGR2GRAY, 1);
cvtColor(src1, src1HLS, COLOR_BGR2GRAY, 1);
cvtColor(src2, src2HLS, COLOR_BGR2GRAY, 1);
cvtColor(src1, src1InY, COLOR_BGR2GRAY, 1);
cvtColor(src2, src2InY, COLOR_BGR2GRAY, 1);

// Apply OpenCV reference threshold
std::cout << "running golden model" << std::endl;
Expand All @@ -153,7 +153,7 @@ int main ( int argc, char** argv )
int numberOfDifferences = 0;
double errorPerPixel = 0;
imageCompare(dstHLS, dstSW, numberOfDifferences, errorPerPixel, true, false);
std::cout << "number of differences: " << numberOfDifferences << " average L2 error: " << errorPerPixel << std::endl;
std::cout << "number of differences: " << numberOfDifferences << " average L1 error: " << errorPerPixel << std::endl;

//write back images in files
if (writeSWResult)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
cmake_minimum_required(VERSION 2.8)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../frameworks/cmakeModules/cmakeModulesXilinx ${CMAKE_CURRENT_SOURCE_DIR}/../../../../frameworks/cmakeModules)
include(rulesForSDxXfOpenCV)
include(rulesForXfOpenCV)
SET(componentName bitwise_not)

createXfOpenCVUnitTestPL("../../../.." ${componentName})
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int main ( int argc, char** argv )
initializeSingleImageTest(fileName, src);

//convert to grayscale
cvtColor(src, gray, CV_BGR2GRAY, 1);
cvtColor(src, gray, COLOR_BGR2GRAY, 1);

if (numberOfIterations > 0) {
HRTimer timer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ int main ( int argc, char** argv )
xF::Mat dstHLS(height, width, CV_8UC1);

//convert 3-channel image into 1-channel image
cvtColor(src, srcHLS, CV_BGR2GRAY, 1);
cvtColor(src, srcInY, CV_BGR2GRAY, 1);
cvtColor(src, srcInY, COLOR_BGR2GRAY, 1);
cvtColor(src, srcHLS, COLOR_BGR2GRAY, 1);
//srcHLS.copyFromCvMat(srcInY);

// Apply OpenCV reference threshold
std::cout << "running golden model" << std::endl;
Expand All @@ -146,7 +147,7 @@ int main ( int argc, char** argv )
int numberOfDifferences = 0;
double errorPerPixel = 0;
imageCompare(dstHLS, dstSW, numberOfDifferences, errorPerPixel, true, false);
std::cout << "number of differences: " << numberOfDifferences << " average L2 error: " << errorPerPixel << std::endl;
std::cout << "number of differences: " << numberOfDifferences << " average L1 error: " << errorPerPixel << std::endl;

//write back images in files
if (writeSWResult)
Expand Down
Loading

0 comments on commit f270218

Please sign in to comment.