OpenCV: Instalation (v3.x)

by Antonio / 2018-10-01
Tags: #opencv

Preparation

Using a Ubuntu/Debian-based OS, it is needed to install the required packages for the compilation, for this, open a console and paste:

sudo apt-get update
sudo apt-get install build-essential cmake git libgtk2.0-dev           \
    pkg-config libavcodec-dev libavformat-dev libswscale-dev           \
    python-dev  python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev \
    libtiff-dev libdc1394-22-dev

Compilation

Download the source code and compile:

cd ~
wget https://github.com/opencv/opencv/archive/3.4.3.tar.gz
tar -xzf 3.4.3.tar.gz
cd opencv-3.4.3/
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j8
sudo make install

Testing

antonio@mint:~$ python

>>> import cv2
>>> cv2.__version__
'3.4.3'
>>>

If the above code gives an error it means the instalation was not done correctly and a verification of the first steps is needed.

References