Linux, OpenCV, Programming, Raspberry Pi

OpenCV 3.4.3 + Raspberry Pi 3B+

Follow these steps to install OpenCV 3.4.3 on a Raspberry Pi 3B+:

1) Install these dependencies:

$ sudo apt-get install build-essential cmake pkg-config
$ sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
$ sudo apt-get install libxvidcore-dev libx264-dev
$ sudo apt-get install libgtk2.0-dev libgtk-3-dev
$ sudo apt-get install libatlas-base-dev gfortran
$ sudo apt-get install python2.7-dev python3-dev

2) Get OpenCV

$ wget
$ unzip
$ rm
$ wget
$ unzip

3) Build & Install OpenCV
NOTE 1: In the cmake line there is a path to the opencv_contrib modules folder, please replace this path with the correct one for your system.

NOTE 2: The make step will take like 8-10 hours and it will crash several times due to low virtual memory. Luckily it can resume from where it crashes so I kept repeating the make command until it finished.

sudo apt-get install python-pip
pip install numpy
$ cd ~/opencv-3.4.3/
$ mkdir build
$ cd build
$ make -j4
$ sudo make install
$ sudo ldconfig

4) Confirm OpenCV installation

$ python
>>> import cv2
>>> cv2.__version__

5) Voila!