OpenVX baseline stack targeting embedded Linux.
Builds OpenCV 4.3.0, OpenVX 1.3 sample impl, and OpenVX samples. Clang toolchain file for RPI3/4 provided.
Use to run opencv examples, opencv test cases, vx tests, or as a template for your RPI Vision project.
export MACHINE=raspberrypi3
export LLVM_ROOT=/path/to/clang/arm/toolchain/root
export TARGET_SYSROOT=/path/to/target/sysroot
git clone https://github.com/jwinarske/rpi-vision
cd rpi-vision
mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=`pwd`/../cmake/clang.toolchain.cmake -GNinja
ninja -j <core count to build with>
Building on target with GCC will not be as performant as when cross compiling with Clang. This is primarily due to CPU tuning flags. The binaries will work, albeit much less performant. If you want optimized tuning when building with GCC on target then you will want to implement a toolchain file that properly implements desired tuning. Building with Yocto will automatically use optimized CPU tuning.
sudo apt get-install cmake
git clone https://github.com/jwinarske/rpi-vision
cd rpi-vision
mkdir build && cd build
cmake .. -DOPENVX_EXPERIMENTAL_USE_VENUM=ON
make -j
ninja package
dpkg -c rpi-vision-Release-0.0.1.0-Linux-armhf.deb
scp rpi-vision-Release-0.1.0-Linux-armhf.deb pi@192.168.1.100:/home/pi
sudo apt install ./rpi-vision-Release-0.1.0-Linux-armhf.deb
sudo apt purge rpi-vision -y
The easiest approach is to mount a fixed up rootfs on your host machine, and point TARGET_SYSROOT to it. This is after you install the required packages, copy sysroot, and fixup the symlinks.
Config | 48 core @ 1Gbps Internet (Ninja) | 16 core @ 48Mbps Internet (Ninja) | RPI3 @ 1Gbps Internet (Uniproc Make) |
---|---|---|---|
real | 5m41.664s | 9m57.577s | 402m3.774s |
user | 17m0.860s | 27m4.504s | 388m5.277s |
sys | 0m18.386s | 0m30.169s | 14m30.165s |
Required with clang.toolchain.cmake
Available values
raspberrypi2
raspberrypi3
raspberrypi-cm3
raspberrypi4
Required with clang.toolchain.cmake
Point to base folder of your cross compiling capable LLVM toolchain
Required with clang.toolchain.cmake
Point to base folder of your target sysroot
Defaults to arm-linux-gnueabihf
if not set. CMake variable of same name can be overriden if clang.toolchain.cmake is not used.
These are used by OpenCV to find gtk-2.0, gtk-ext1, and openGL libraries in the target sysroot.
Defaults to Release
if not set otherwise
Use to set install prefix. With Linux the default value is /usr/local
Defaults to 4.3.0
Defaults to openvx_1.3
Defaults to master
Builds the openvx_tutorial repo. Defaults to ON
Builds the opencv_v4l2 repo. Defaults to ON
Build OpenCV with Non-Free Support. Defaults to ON
Build OpenCV with QT. Defaults to OFF
Build OpenCV with GTK. Defaults to ON
Build OpenCV with GTK_2_X. Defaults to ON
Build OpenCV with OpenGL. Defaults to ON
Build OpenCV with OpenVX. Defaults to ON
Build OpenCV with TEngine. Defaults to OFF
Note: this requires a change to the TENGINE repo. Toolchain tuning should be isolated to a toolchain file.
File to change: build/opencv-prefix/src/opencv-build/3rdparty/libtengine/Tengine-<commit>/CMakeLists.txt
Comment out as below.
if(CONFIG_ARCH_ARM32)
add_definitions(-DCONFIG_ARCH_ARM32=1)
# if(NOT ANDROID)
# add_definitions(-march=armv7-a -mfpu=neon -mfp16-format=ieee -mfpu=neon-fp16)
# set(ARCH_TYPE,"Arm32")
# endif()
endif()
Build OpenCV with Vulkan Support. Defaults to OFF
Build OpenCV with Tests. Defaults to OFF
Build OpenCV with Examples. Defaults to OFF
Install Python Examples with OpenCV build. Defaults to OFF
Builds OpenCV with -mfpu=vfpv3. Defaults to OFF
Use with GCC or when using a Generic Triple with Clang
Builds OpenCV with -mfpu=neon. Defaults to OFF
Use with GCC or when using a Generic Triple with Clang
You may need to set this when not using clang.toolchain.cmake.
ssh pi@192.168.1.100
mkdir test_data
exit
cd build
scp -rp openvx-impl-prefix/src/openvx-impl/cts/test_data/* pi@192.168.1.100:/home/pi/test_data
ssh pi@192.168.1.100
cd test_data
vx_test_conformance > log 2>&1
Enable OpenCV tests by setting BUILD_OPENCV_WITH_TESTS=ON
OpenCV tests were implemented with CTest, and paths are setup to run form the build folder. When cross compiling there is a minor change to run them.
export LD_LIBRARY_PATH=/usr/local/lib/tls/v7l/neon/vfp
opencv_perf_core
opencv_perf_calib3d
opencv_perf_core
opencv_perf_dnn
opencv_perf_features2d
opencv_perf_gapi
opencv_perf_imgcodecs
opencv_perf_imgproc
opencv_perf_objdetect
opencv_perf_photo
opencv_perf_stitching
opencv_perf_video
opencv_perf_videoio
=================================
OpenVX Conformance report summary
=================================
To be conformant to the OpenVX baseline, 5563 required test(s) must pass. 5563 tests passed, 0 tests failed. PASSED.
To be conformant to the Vision conformance profile, 5909 required test(s) must pass. 5909 tests passed, 0 tests failed. PASSED.
To be conformant to the enhanced vision conformance profile, 1221 required test(s) must pass. 1221 tests passed, 0 tests failed. PASSED.
Note: The 8190 disabled tests are optional and are not considered for conformance.
#REPORT: 20200717095309 ALL 16271 8190 6784 6784 6784 0 (version 1.3)
The lowest latency I have seen with OpenCV and the Raspberry PI HQ camera is the access pattern used by "opencv-v4l2-gl-display".