bimalka98 / Optimized-OpenCV-for-RPi

A pre-compiled version of OpenCV 4.4.0 for Raspberry Pi optimized for deep learning / computer vision with TBB, NEON and VFPV3 enabled ⚡

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Optimized OpenCV for RPi

OpenCV is a highly optimized library. Most of its functions have different implementations for different processors: this way, the code can be specifically tuned to use the capabilities of the chips. The optimized code often uses some specific hardware-related functions, or instructions sets: for example, Intel CPUs support SSE, AVX and other instruction sets, and ARM chips support VFP and NEON instructions. Different versions of Raspberry board are built with different generations of ARM chips. Each of them has different vectorization and optimization capabilities, and thus supports different instruction subsets. OpenCV can be significantly optimized by letting it know more details of your hardware during the compilation. paragraph copied from LearnOpenCV.com 😅

However this process is extremely time consuming and can take up to anywhere between 2-4 hours or may be even more, depending on the number of cores that will bee used to build OpenCV. In addition to that if the excess heat generated by the RPi is not controlled well, the build process can stuck in the middle leading to great frustration. (saying this by experience 😂😂). Fortunately I could find this precompiled version at the end and words fail to thank Dario Limongi for making the package publicly available. ❤ I have tried it with C++ and it works smoothly.


Content from the original repository:

Faster OpenCV for Raspberry Pi

Leverage all your CPUs power in OpenCV by using TBB, Neon and VFPV3 libraries.

Since I've already compiled this on my own Raspberry Pi I made it available on GitHub.

Save countless of compile time by just installing these debs. Enjoy!

What is this?

  • A pre-compiled OpenCV 4.4.0 for Raspberry Pi optimized for deep learning / computer vision applications (NEON, VFPV3, TBB turned on).
  • Bindings for Python 2 and Python 3 are also included.
  • For detailed build informations click here.
  • Created with OpenCV cpack targets.
  • Tested on Raspberry Pi 3 using Raspbian Buster (Debian 10) (for Raspbian Stretch click here).

How much faster?

Performance tests have been made in this great blog article which led to an approximate 30% increase in speed and of over 48% when applied strictly to DNN module.

Another performance test is available here which also led to about 30% increase in speed.

How to use it?

Install OpenCV library prerequisites on your Raspberry Pi.

sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y \
	libjpeg-dev libpng-dev libtiff-dev libgtk-3-dev \
	libavcodec-extra libavformat-dev libswscale-dev libv4l-dev \
	libxvidcore-dev libx264-dev libjasper1 libjasper-dev \
	libatlas-base-dev gfortran libeigen3-dev libtbb-dev

Install numpy based on your target Python version:

sudo apt-get install -y python3-dev python3-numpy

or:

sudo apt-get install -y python-dev python-numpy

How to install?

Clone the repo into your Raspberry Pi and install all debs:

git clone https://github.com/dlime/Faster_OpenCV_4_Raspberry_Pi.git
cd Faster_OpenCV_4_Raspberry_Pi/debs
sudo dpkg -i OpenCV*.deb
sudo ldconfig

How to test?

C++

Test the installation by going to tests cpp test folder, build it and launch the executable:

cd Faster_OpenCV_4_Raspberry_Pi/tests/cpp_opencv_test
mkdir build && cd build
cmake ..
make -j`cat /proc/cpuinfo | grep -c 'processor'`
./cpp_opencv_test

Python

Test the installation by going to tests folder and launch the test.py file:

cd Faster_OpenCV_4_Raspberry_Pi/tests/python_opencv_test
python test.py

You shouldn't see any error messages in console and an image with tetris blocks with contours drawed should appear.

How to uninstall?

Run the following command in your Raspberry Pi terminal:

sudo apt purge opencv-*

About

A pre-compiled version of OpenCV 4.4.0 for Raspberry Pi optimized for deep learning / computer vision with TBB, NEON and VFPV3 enabled ⚡

License:BSD 2-Clause "Simplified" License


Languages

Language:C++ 50.2%Language:Python 39.4%Language:CMake 10.4%