loading...
  1. Easiest way to install OpenCV on Ubuntu 16.04 (Python + C++ Support)

Easiest way to install OpenCV on Ubuntu 16.04 (Python + C++ Support)

Hello Friends,

I recently stumbled upon a script which i think is the easiest way to install OpenCV with Python and C++ support on Ubuntu 16.04 or Debian build.
You just need to copy the below script and create a file “install_opencv.sh” and paste everything in there.
Fire up the script using sudo command and enjoy your coffee/food break while everything will be setup on its own.

This is probably the easiest method to install OpenCV on Ubuntu.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
######################################
# INSTALL OPENCV ON UBUNTU OR DEBIAN #
# SCRIPT FROM PYTHONOPENCV.COM
######################################
 
# |         THIS SCRIPT IS TESTED CORRECTLY ON         |
# |----------------------------------------------------|
# | OS             | OpenCV       | Test | Last test   |
# |----------------|--------------|------|-------------|
# | Ubuntu 16.04.2 | OpenCV 3.2.0 | OK   | 20 May 2017 |
# | Debian 8.8     | OpenCV 3.2.0 | OK   | 20 May 2017 |
# | Debian 9.0     | OpenCV 3.2.0 | OK   | 25 Jun 2017 |
 
# 1. KEEP UBUNTU OR DEBIAN UP TO DATE
 
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove
 
 
# 2. INSTALL THE DEPENDENCIES
 
# Build tools:
sudo apt-get install -y build-essential cmake
 
# GUI (if you want to use GTK instead of Qt, replace 'qt5-default' with 'libgtkglext1-dev' and remove '-DWITH_QT=ON' option in CMake):
sudo apt-get install -y qt5-default libvtk6-dev
 
# Media I/O:
sudo apt-get install -y zlib1g-dev libjpeg-dev libwebp-dev libpng-dev libtiff5-dev libjasper-dev libopenexr-dev libgdal-dev
 
# Video I/O:
sudo apt-get install -y libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev yasm libopencore-amrnb-dev libopencore-amrwb-dev libv4l-dev libxine2-dev
 
# Parallelism and linear algebra libraries:
sudo apt-get install -y libtbb-dev libeigen3-dev
 
# Python:
sudo apt-get install -y python-dev python-tk python-numpy python3-dev python3-tk python3-numpy
 
# Java:
sudo apt-get install -y ant default-jdk
 
# Documentation:
sudo apt-get install -y doxygen
 
 
# 3. INSTALL THE LIBRARY (YOU CAN CHANGE '3.2.0' FOR THE LAST STABLE VERSION)
 
sudo apt-get install -y unzip wget
wget https://github.com/opencv/opencv/archive/3.2.0.zip
unzip 3.2.0.zip
rm 3.2.0.zip
mv opencv-3.2.0 OpenCV
cd OpenCV
mkdir build
cd build
cmake -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON -DENABLE_PRECOMPILED_HEADERS=OFF ..
make -j4
sudo make install
sudo ldconfig




1 thought on “Easiest way to install OpenCV on Ubuntu 16.04 (Python + C++ Support)”

  1. Editor says:

    Make sure to run this script in virtual environment if you are using them.

Leave a Reply

Your email address will not be published. Required fields are marked *

Welcome to OpenCV World !! Come as a Guest, stay as a Family