2011-06-24 05:55:24 +08:00
.. _Linux-Installation:
Installation in Linux
2012-10-11 20:44:53 +08:00
***** ***** ***** ***** *
These steps have been tested for Ubuntu 10.04 but should work with other distros as well.
2011-06-24 05:55:24 +08:00
2012-10-11 20:44:53 +08:00
Required Packages
=================
2011-06-24 05:55:24 +08:00
2012-10-11 20:44:53 +08:00
* GCC 4.4.x or later. This can be installed with:
2011-06-24 05:55:24 +08:00
.. code-block :: bash
2013-08-21 20:44:09 +08:00
sudo apt-get install build-essential
2014-01-17 18:50:40 +08:00
* CMake 2.8.7 or higher;
2012-10-11 20:44:53 +08:00
* Git;
* GTK+2.x or higher, including headers (libgtk2.0-dev);
2014-01-10 00:24:20 +08:00
* pkg-config;
2012-10-11 20:44:53 +08:00
* Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy);
* ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev;
* [optional] libdc1394 2.x;
2012-04-14 05:50:59 +08:00
* [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev.
2011-06-24 05:55:24 +08:00
2012-10-11 20:44:53 +08:00
All the libraries above can be installed via Terminal or by using Synaptic Manager.
2011-06-24 05:55:24 +08:00
2012-10-11 20:44:53 +08:00
Getting OpenCV Source Code
==========================
2011-06-24 05:55:24 +08:00
2012-10-11 20:44:53 +08:00
You can use the latest stable OpenCV version available in *sourceforge* or you can grab the latest snapshot from our `Git repository <https://github.com/Itseez/opencv.git> `_ .
2011-06-24 05:55:24 +08:00
2012-10-11 20:44:53 +08:00
Getting the Latest Stable OpenCV Version
----------------------------------------
2011-06-24 05:55:24 +08:00
2012-10-11 20:44:53 +08:00
* Go to our `page on Sourceforge <http://sourceforge.net/projects/opencvlibrary> `_ ;
2011-06-24 05:55:24 +08:00
2012-10-11 20:44:53 +08:00
* Download the source tarball and unpack it.
2011-06-24 05:55:24 +08:00
2012-10-11 20:44:53 +08:00
Getting the Cutting-edge OpenCV from the Git Repository
-------------------------------------------------------
2011-06-24 05:55:24 +08:00
2012-10-11 20:44:53 +08:00
Launch Git client and clone `OpenCV repository <http://github.com/itseez/opencv> `_
2011-06-24 05:55:24 +08:00
2012-10-11 20:44:53 +08:00
In Linux it can be achieved with the following command in Terminal:
2011-06-24 05:55:24 +08:00
.. code-block :: bash
cd ~/<my_working _directory>
2012-10-11 20:44:53 +08:00
git clone https://github.com/Itseez/opencv.git
2013-08-21 20:44:09 +08:00
2011-06-24 05:55:24 +08:00
2012-10-11 20:44:53 +08:00
Building OpenCV from Source Using CMake, Using the Command Line
===============================================================
2011-06-24 05:55:24 +08:00
2012-10-11 20:44:53 +08:00
#. Create a temporary directory, which we denote as <cmake_binary_dir>, where you want to put the generated Makefiles, project files as well the object files and output binaries.
2011-06-24 05:55:24 +08:00
#. Enter the <cmake_binary_dir> and type
.. code-block :: bash
2013-08-21 20:44:09 +08:00
2011-06-24 05:55:24 +08:00
cmake [<some optional parameters> ] <path to the OpenCV source directory>
For example
.. code-block :: bash
2013-08-21 20:44:09 +08:00
2011-06-24 05:55:24 +08:00
cd ~/opencv
mkdir release
cd release
2012-04-30 22:33:52 +08:00
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
2013-08-21 20:44:09 +08:00
2011-06-24 05:55:24 +08:00
#. Enter the created temporary directory (<cmake_binary_dir>) and proceed with:
.. code-block :: bash
2013-08-21 20:44:09 +08:00
2011-06-24 05:55:24 +08:00
make
sudo make install
2011-08-19 18:12:33 +08:00
.. note ::
2013-08-21 20:44:09 +08:00
2011-08-19 18:12:33 +08:00
If the size of the created library is a critical issue (like in case of an Android build) you can use the `` install/strip `` command to get the smallest size as possible. The *stripped* version appears to be twice as small. However, we do not recommend using this unless those extra megabytes do really matter.