I've downloaded opencv but unfortunately I've got no idea how to install it. All the pages I found online were only telling me how to download and install it directly from the console, not what to do when you already have it downloaded. Could anybody tell me what to do?

  • 4
    There is a lot of opencv libs in the software center or in apt. Not sure whether it is a standalone as such too?
    – don.joey
    Aug 18 '13 at 15:19

To Install OpenCV on Ubuntu, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

Ubuntu 12.04 provides a package of OpenCV 2.3.1 that you can easily install by typing:

sudo apt-get install libopencv-dev

If you do not care about having the latest version you could skip the rest.

Install Dependencies

sudo apt-get install build-essential checkinstall cmake pkg-config yasm
sudo apt-get install libtiff4-dev libjpeg-dev libjasper-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev 
libgstreamer-plugins-base0.10-dev libv4l-dev
sudo apt-get install python-dev python-numpy
sudo apt-get install libtbb-dev
sudo apt-get install libqt4-dev libgtk2.0-dev

Download OpenCV for Unix to: ~/Downloads

cd Downloads
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/

tar -xvf opencv-
cd opencv-
mkdir build
cd build

Configure using CMake.


Notice, that by adding the -D WITH_QT=ON, the highgui module will use QT instead of GTK. If you want to go with GTK just remove this. For more information on the options, look at the CMakeLists.txt file. When you are happy with the configuration you have, you can start compiling:


If compilation finishes without errors, you can install by saying:

sudo make install

Finally, make sure that your programs can link to the OpenCV library in run-time by adding the following line at the end of your /etc/ld.so.conf:


And then configure dynamic linker run-time bindings:

sudo ldconfig

Source:How To Install OpenCV on Ubuntu

  • 1
    As of writing, the libopencv-dev fails to install the folder /usr/include/opencv, containing the 'old' header files. They are present in (the original source)[archive.ubuntu.com/ubuntu/pool/universe/o/opencv/… and the folder is referenced in the pkg-config file opencv.pc, so downloading and unzipping the original source, then linking/copying the include/opencv folder into /usr/include works.
    – drevicko
    Apr 6 '14 at 5:03
  • Hi @drevicko! could you explain more on your answer? I'm a bit novice to grasp the idea of "linking/copying" the include/opencv. How may I do that?
    – Shawn Le
    Jul 6 '14 at 6:08
  • I presume you've found the folder opencv in the folder include in the unpacked archive from the link above? And installed libopencv-dev from a terminal? Check the installed version matches the link above ('2.3.1-11ubuntu2' should be in the output of apt-cache showpkg libopencv-dev) - if not, don't do the following: Lets say you downloaded and unpacked the link above into your home folder. In a terminal, do cd /usr/include then to link do sudo ln -s ~/opencv_2.3.1.orig/include/opencv or to copy do sudo cp ~/opencv_2.3.1.orig/include/opencv .
    – drevicko
    Jul 9 '14 at 16:30

It has since become easier to install OpenCV on Ubuntu16.04+.

According to the OPenCV pypi page, from Ubuntu 16.04+, you can do this to install OpenCV:

  • For Python2.7:

    pip install opencv-python
  • For python3:

    pip3 install opencv-python

For more information, see.


Here's a script to help install opencv 2.4.8 based on an ancient FFmpeg release on Ubuntu.


wget -O- https://gist.github.com/olupotd/cd0c68f4c84153dffd16 | sh 

Here is a script I've made myself. The problem I found with other scripts around are that they do not stop when one command fails. It just blindly follows to the next command, and eventually you end up with no installation.

This script automatically checks for dependencies on the official website, downloads the most stable release, and install it on your system. I've tested it on 14.04 only, and have installed it on several systems with no issues.

To use the script, the download file from here, open a terminal, cd to the directory containing the script and type:

chmod u+x install_opencv_latest.sh

Now just execute the script:


You will be asked to enter your administrative password, and confirm installation 2-3 times. Just press Y. It will take 10-20 minutes accordind to your specs.

Note that you need to cd to the directory in which you downloaded the script, which would most probably be your Downloads folder:

cd ~/Downloads

A good place to look for installation instructions is the OpenCV website.

As of writing, linux installation instructions for the latest version (opencv 3.2.0) are here:


Not the answer you're looking for? Browse other questions tagged or ask your own question.