Home - C++ Programming - My Programs - Computer Vision - Augmented Reality - Gallery - Contact Me


--------------------------------------------------------------

Installing openCV on Linux from Scratch:

This are instructions to install OpenCV on a Devian or derived Linuxes distros.

This method has been tested on Ubuntu 10.04 and Mint 14.

The OpenCV installation has some basic steps.

First it is imporant to download all the necesary pakages. This are libraries which OpenCV is dependent on and the OpenCV File themself.

To download and get this libraries install all that is required is to use the command "apt get-istall" on the terminal. One will need to have super user permition for this.

The following is a list of the libraryes to download:

----------

sudo apt-get install build-essential checkinstall cmake pkg-config yasm

----------

sudo apt-get install libgtk2.0-dev python-dev python-numpy

----------

sudo apt-get install libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev pngtools libjasper-dev libjasper-runtime libjasper1 libjpeg8 libjpeg8-dbg libjpeg8-dev libjpeg libjpeg-progs libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools ffmpeg libavcodec-dev libavcodec53 libavformat53 libavformat-dev libswscale0 libswscale-dev openexr libopenexr6 libopenexr-dev

----------

sudo apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libxine1-ffmpeg libxine-dev libxine1-bin libunicap2 libunicap2-dev libdc1394-22-dev libdc1394-22 libdc1394-utils libv4l-0 libv4l-dev libx264-dev sphinx-common libv4l-dev libtbb-dev libtbb2

----------

------- To compile with CUDA support: ---------

sudo apt-get install nvidia_current libcudart4 nvidia-cuda-dev nvidia-cuda-toolkit

----------

Some packages may change version an others may be depraqueted. But usualy the apt command will warn you of any errors.

Once the Packages are downloded one needs to get a copy of the OpenCV library. this can be done by heading over to their bewpage athttp://opencv.org/. Here is the link to all the versions of OpenCV at Sourceforge for any OS.

Once you have downloaded the appropiate file for your linux OS and descompresed, you can make a folder with in the descompressed folder where you are going to compile the OpenCV library.

The usual convention is to name this folder Release. So for example if I have decompres the OpenCV files on my home folder. I will have to go to that folder by doing:

----------

cd home/opencv

----------

Once in the opencv folder, the release folder can be made by doing:

----------

mkdir release

----------

then we can enter thsi new folder for compiling the openCV into it.

Before we can compile, the projects needs to be set up. At this stage one can set different parameters such as if we want to use gtk or Qt for the GUI.

with out going to much into ditail the command we are going to run here is as follow:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_V4L=ON -D WITH_GSTREAMER=ON -D WITH_OPENEXR=ON -D WITH_UNICAP=ON -D BUILD_PYTHON_SUPPORT=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_TBB=ON ..

It may need to have a sudo prior to the command dependiong if one created the release folder with superuser permition.

The above command will configure all the parameters so that we can make the OpenCV Project.

The output should look something like this:

--------------------------------------------------------

I-- Detected version of GNU GCC: 47 (407)

-- Found OpenEXR: /usr/lib/libIlmImf.so

-- checking for module 'libucil'

-- package 'libucil' not found

-- Looking for linux/videodev.h

-- Looking for linux/videodev.h - not found

-- Looking for linux/videodev2.h

-- Looking for linux/videodev2.h - found

-- Looking for sys/videoio.h

-- Looking for sys/videoio.h - not found

-- Looking for libavformat/avformat.h

-- Looking for libavformat/avformat.h - found

-- Looking for ffmpeg/avformat.h

-- Looking for ffmpeg/avformat.h - not found

CUDA_TOOLKIT_ROOT_DIR not found or specified

-- Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (Required is at least version "4.2")

--

-- General configuration for OpenCV 2.4.9 =====================================

-- Version control: 2.4.4-beta-577-g262fc92-dirty

--

-- Platform:

-- Host: Linux 3.5.0-17-generic x86_64

-- CMake: 2.8.9

-- CMake generator: Unix Makefiles

-- CMake build tool: /usr/bin/make

-- Configuration: RELEASE

--

-- C/C++:

-- Built as dynamic libs?: YES

-- C++ Compiler: /usr/bin/c++ (ver 4.7.2)

-- C++ flags (Release): -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG -DNDEBUG

-- C++ flags (Debug): -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g -O0 -DDEBUG -D_DEBUG -ggdb3

-- C Compiler: /usr/bin/gcc

-- C flags (Release): -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG -DNDEBUG

-- C flags (Debug): -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g -O0 -DDEBUG -D_DEBUG -ggdb3

-- Linker flags (Release):

-- Linker flags (Debug):

-- Precompiled headers: YES

--

-- OpenCV modules:

-- To be built: core imgproc flann highgui features2d calib3d ml video objdetect contrib nonfree photo legacy gpu softcascade python stitching ts videostab

-- Disabled: world

-- Disabled by dependency: -

-- Unavailable: androidcamera java ocl

--

-- GUI:

-- QT 4.x: NO

-- GTK+ 2.x: YES (ver 2.24.13)

-- GThread : YES (ver 2.34.1)

-- GtkGlExt: NO

-- OpenGL support: NO

--

-- Media I/O:

-- ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.7)

-- JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )

-- PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.49)

-- TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 3.9.6)

-- JPEG 2000: /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)

-- OpenEXR: /usr/lib/libImath.so /usr/lib/libIlmImf.so /usr/lib/libIex.so /usr/lib/libHalf.so /usr/lib/libIlmThread.so (ver 1.6.1)

--

-- Video I/O:

-- DC1394 1.x: NO

-- DC1394 2.x: YES (ver 2.2.0)

-- FFMPEG: YES

-- codec: YES (ver 53.35.0)

-- format: YES (ver 53.21.1)

-- util: YES (ver 51.22.1)

-- swscale: YES (ver 2.1.0)

-- gentoo-style: YES

-- GStreamer:

-- base: YES (ver 0.10.36)

-- app: YES (ver 0.10.36)

-- video: YES (ver 0.10.36)

-- OpenNI: NO

-- OpenNI PrimeSensor Modules: NO

-- PvAPI: NO

-- GigEVisionSDK: NO

-- UniCap: NO

-- UniCap ucil: NO

-- V4L/V4L2: Using libv4l (ver 0.8.8)

-- XIMEA: NO

-- Xine: NO

--

-- Other third-party libraries:

-- Use IPP: NO

-- Use Eigen: YES (ver 3.0.93)

-- Use TBB: YES (ver 4.0 interface 6000)

-- Use OpenMP: NO

-- Use GCD NO

-- Use Concurrency NO

-- Use C=: NO

-- Use Cuda: NO

-- Use OpenCL: NO

--

-- Python:

-- Interpreter: /usr/bin/python2 (ver 2.7.3)

-- Libraries: /usr/lib/python2.7/config/libpython2.7.so (ver 2.7.3)

-- numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.6.2)

-- packages path: lib/python2.7/dist-packages

--

-- Java:

-- ant: NO

-- JNI: NO

-- Java tests: YES

--

-- Documentation:

-- Build Documentation: NO

-- Sphinx: NO

-- PdfLaTeX compiler: NO

--

-- Tests and samples:

-- Tests: YES

-- Performance tests: YES

-- C/C++ Examples: YES

--

-- Install path: /usr/local

--

-- cvconfig.h is in: /home/tony/opencv/opencv/release

-- -----------------------------------------------------------------

--

-- Configuring done

-- Generating done

----------

After configuring, once can make running the command:

----------

make

----------

Make can take some time, so go for a cup of cofeee or something. And after it is finnish it can be install by wunning

----------

sudo make install

----------

All that is left after that is to set up the environment variable as follow:

----------

export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH

sudo ldconfig

----------

And that should be everything. now you should be able to compile any C++ program you want to make with opencv. You should have a look at the sample programs OpenCV brings with itself. And check you can build them with ./build_all.sh shell command.