Giter VIP home page Giter VIP logo

dlime / faster_opencv_4_raspberry_pi Goto Github PK

View Code? Open in Web Editor NEW
58.0 5.0 16.0 119.11 MB

A pre-compiled version of OpenCV 4 for Raspberry Pi optimized for deep learning / computer vision..

License: BSD 2-Clause "Simplified" License

Python 39.38% CMake 10.45% C++ 50.17%
raspberry-pi neon python2-python3 vfpv3 deep-learning opencv4 opencv3-python opencv-python debian-packages raspbian

faster_opencv_4_raspberry_pi's Introduction

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-*

faster_opencv_4_raspberry_pi's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

faster_opencv_4_raspberry_pi's Issues

Thanks plus one more quick question.

Thank you very much man. By now I failed 4 times while building OpenCV for my Pi 3, lots of errors. You scripts just made it simple. How do I use OpenCV in a python virtual environment?

dpkg: error processing package opencv-python:armhf

I am building a docker using raspberrypi base image
https://hub.docker.com/r/dtcooper/raspberrypi-os

first issue I was getting is failing to install these libs
libjasper1 libjasper-dev
spend some hours finding a workaround without luck.
so I have skipped that part from your manual.

then when running
dpkg -i OpenCV*.deb &&

I have got this

`Unpacking opencv-scripts:armhf (4.4.0) ...
dpkg: dependency problems prevent configuration of opencv-dev:armhf:
opencv-dev:armhf depends on libc6 (>= 2.4).
opencv-dev:armhf depends on libgcc1 (>= 1:3.5).
opencv-dev:armhf depends on libstdc++6 (>= 5.2).

dpkg: error processing package opencv-dev:armhf (--install):
dependency problems - leaving unconfigured
Setting up opencv-licenses:armhf (4.4.0) ...
dpkg: dependency problems prevent configuration of opencv-libs:armhf:
opencv-libs:armhf depends on libavcodec58 (>= 7:4.0).
opencv-libs:armhf depends on libavformat58 (>= 7:4.1).
opencv-libs:armhf depends on libavutil56 (>= 7:4.0).
opencv-libs:armhf depends on libc6 (>= 2.28).
opencv-libs:armhf depends on libcairo2 (>= 1.2.4).
opencv-libs:armhf depends on libfreetype6 (>= 2.2.1).
opencv-libs:armhf depends on libgcc1 (>= 1:4.0).
opencv-libs:armhf depends on libgdk-pixbuf2.0-0 (>= 2.22.0).
opencv-libs:armhf depends on libglib2.0-0 (>= 2.31.8).
opencv-libs:armhf depends on libgtk-3-0 (>= 3.0.0).
opencv-libs:armhf depends on libharfbuzz0b (>= 0.9.9).
opencv-libs:armhf depends on libjasper1.
opencv-libs:armhf depends on libjpeg62-turbo (>= 1.3.1).
opencv-libs:armhf depends on libpng16-16 (>= 1.6.2-1).
opencv-libs:armhf depends on libstdc++6 (>= 7).
opencv-libs:armhf depends on libswscale5 (>= 7:4.0).
opencv-libs:armhf depends on libtbb2.
opencv-libs:armhf depends on libtiff5 (>= 4.0.3).
opencv-libs:armhf depends on zlib1g (>= 1:1.2.0).

dpkg: error processing package opencv-libs:armhf (--install):
dependency problems - leaving unconfigured
Setting up opencv-scripts:armhf (4.4.0) ...
dpkg: dependency problems prevent configuration of opencv-main:armhf:
opencv-main:armhf depends on libc6 (>= 2.4).
opencv-main:armhf depends on libgcc1 (>= 1:3.5).
opencv-main:armhf depends on libstdc++6 (>= 5.2).

dpkg: error processing package opencv-main:armhf (--install):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of opencv-python:armhf:
opencv-python:armhf depends on libc6 (>= 2.4).
opencv-python:armhf depends on libgcc1 (>= 1:3.5).
opencv-python:armhf depends on libstdc++6 (>= 5.2).

dpkg: error processing package opencv-python:armhf (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
opencv-dev:armhf
opencv-libs:armhf
opencv-main:armhf
opencv-python:armhf
The command '/bin/sh -c cd Faster_OpenCV_4_Raspberry_Pi/debs && dpkg -i OpenCV*.deb && ldconfig' returned a non-zero code: 1
`
ca you please help ?

Dockerfile

FROM dtcooper/raspberrypi-os:bullseye
RUN apt-get update && sudo apt-get upgrade -y && apt-get -y install libglib2.0-0; apt-get clean
RUN apt install -y python2
RUN apt-get install -y curl
RUN curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
RUN python2.7 get-pip.py
RUN apt-get install -y python2-dev
RUN apt-get install -y zip
RUN apt-get install -y wget

RUN 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
libatlas-base-dev gfortran libeigen3-dev libtbb-dev

RUN apt-get install -y libatlas-base-dev gfortran
RUN pip2 install numpy

RUN apt-get install -y git
RUN git clone https://github.com/dlime/Faster_OpenCV_4_Raspberry_Pi.git
RUN cd Faster_OpenCV_4_Raspberry_Pi/debs &&
dpkg -i OpenCV*.deb &&
ldconfig`
I am desperately trying to build a docker for a big program I have build years ago
It runs python2.7 and opencv 4 over raspberry pi 3+.
After a week of failing to build or finding any ready source I cam across your git
please help

No module named 'cv2'

After installation I get the message

File "/home/pi/Faster_OpenCV_4_Raspberry_Pi/tests/python_opencv_test/test.py", line 6, in
import cv2
ModuleNotFoundError: No module named 'cv2'

so I'm not stupid I tried but obviously he can't find the lib

Wrong install path

In the build_information.txt there is install path /usr/local but all .deb packages install libraries to /usr path. This leads to the wrong configuration in CMake using pkg-config. I had to manually fix the issue in my scripts using this command: sed -i 's/prefix=\/usr\/local/prefix=\/usr/' /usr/lib/pkgconfig/opencv4.pc

I suggest editing the build configuration to /usr and reupload packages

Anyway, these deb packages helped me a lot in my RPI project!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.