2. Configuration – Installing OpenCV

Welcome back!

Today I would like to write something about the basic software I am using to program. I will program in C++ and use a library called OpenCV, it’s the most used open source computer vision library, and there is extensive documentation, examples and tutorials, I intent to do a post especifically about all the functionalities and examples of use of OpenCV but while I don’t, more information can be found here

http://docs.opencv.org/index.html

Although the OpenCV is utilized by a lot of people, and there is a lot of support online, every time I have to install it, I end up following a diferent tutorial, with diferent configurations, and sometimes even ended up installing an older version. Today I found a pretty amazing tutorial at github and would like to share it with all of you.

http://milq.github.io/install-opencv-ubuntu-debian/

I will write a summary of things here just for reference.

1. Update Ubuntu

sudo apt-get update
sudo apt-get upgrade

2. Install Dependencies

Build tools:

sudo apt-get install build-essential cmake

GUI:

sudo apt-get install qt5-default libvtk6-dev

Media I/O:

sudo apt-get install zlib1g-dev libjpeg-dev libwebp-dev libpng-dev libtiff5-dev libjasper-dev libopenexr-dev libgdal-dev

Video I/O:

sudo apt-get install libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libv4l-dev libxine2-dev

Parallel programming:

sudo apt-get install libtbb-dev libeigen3-dev

Phyton:

sudo apt-get install python-dev python-tk python-numpy python3-dev python3-tk python3-numpy

Java:

sudo apt-get install ant default-jdk

Documentation:

sudo apt-get install sphinx-common texlive-latex-extra

3. Download and decompress OpenCV

Enter opencv.org and download the latest version available.
Decompress it in the file you choose.

4. Compile and install OpenCV

Use the cd command to navigate to your OpenCV directory. Then put the following in the terminal

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 ..
make -i
sudo make install

That should install the OpenCV in your system, just open an example, compile and run it in the terminal to be sure everything went according to the expectations.

Thats all for now!

Igor Hueb de Castro