Friday, 29 January 2016

openCV installation

Installation in Windows:

On the home page of opencv,they have already mentioned how to install the openCV library in windows and configuring it to visual studio.
It is not necessary that you need visual studio. Any C++ compiler/ IDE can be used such as codeblocks compiler (Courtesy STAB IIT Bombay check the link).
First Download the  codeblocks and select "codeblocks-13.12mingw-setup.exe" file. After the installation is complete reboot the system.
Download the opencv2.0 library for windows and during the installation you will be asked about the system path.
Select the option "Add openCV to the system path for all users".
Later in the compiler options-->Search directories-->Compiler and add the include folder of openCV. (Note: BE SURE NOT TO KEEP THE PATH RELATIVE FOR THESE STEPS.)
Next goto compiler options-->Search directories-->Linker and add the lib folder

Next goto compiler options-->Linker Settings and add all the contents of the lib folder one at a time.
Thats it. Now openCV has been configured and can be used to start implementing.
Note: openCV 2.0 has only the basic libraries (which do not include the folder opencv2) so for an introduction to image processing using openCV it is useful. If the advanced functions ( > 2.0) are required the please follow the steps for openCV>2.0 However the installation of this library requires additional 10 software(CMake,tortoise SVN/Git, Miktex, Python, Numpy, Intel Threading blocks, CUDA, Eigen, openEXR, openNI and SphinX) to to downloaded and installed separately. Thus it is recommended to use linux (Ubuntu, Fedora, Linux Mint, Debian etc..) for using openCV.
___________________________________________________________________________________________________________________________________________________

Installation in Linux:

If you check out the home page of opencv, they have already mentioned how to install the software in linux however, I faced some difficulties after the installation so I checked for errors and dependency issues and made a complete step-by-step procedure for installing openCV in Linux. You an also follow the steps mentioned in this web page if you are facing those issues.

Note:I have tested on Ubuntu and Linux Mint so far. It should work for other Debian based distributions as well.

The following are my sources if you would like to explore. Enjoy!!!

Installation Steps:

These instructions can be directly copy-pasted to the terminal in linux. The only assumption is that there is a working Internet connection. It supports the latest openCV currently version 3.1.0.

Install all pre requisites

Ubuntu provides a package of OpenCV 2.x.x 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 of the post however while interfacing with eclipse you may face some issues so it is recommended to follow all the instructions.
Depends on which version of linux you are using.

Simply Copy paste the following into your terminal screen it will install the necessary softwares and dependencies required.

sudo apt-get install libopencv-dev  build-essential checkinstall cmake pkg-config yasm libtiff4-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libeigen3-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev libjasper-dev libjasper-runtime libjasper1 pngtools libtiff4-dev  libtiff-tools libjpeg8 libjpeg8-dev libjpeg8-dbg  libavcodec-dev libavformat-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev libxine1-ffmpeg libxine-dev libxine1-bin libunicap2 libunicap2-dev libdc1394-22-dev libdc1394-22 libdc1394-utils swig libv4l-0 libv4l-dev libeigen2-dev libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev


(Even after here also you can use openCV however to ensure that the library is properly configured please proceed ahead)

Installation from the tar file

Download the source code from openCV homepage.Next go to the directory where OpenCV is downloaded via the terminal only and then un zip the package:

Note:- It is recommended that you move the downloaded OpenCV package to the home/<user>/ 

unzip OpenCV-2.x.x.zip
cd OpenCV-2.x.x/
Now make a new directory (folder) called "build" for building the software. Use the following commands.

mkdir build
cd build
Later run Cmake with the following commands
cmake -D WITH_TBB=ON -D WITH_QT=ON -D WITH_XINE=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D WITH_OPENGL=ON -D BUILD_EXAMPLES=ON ..
Now make the files
make

Now we make it permanent
 
sudo make install

Configuring OpenCV:

The installation is nearly complete so now we have to configure with the OS to use gcc or any ide(e.g. eclipse) to compile and run the programs.

sudo gedit /etc/ld.so.conf.d/opencv.conf

Add the following line at the end of the file (it may be an empty file, that is ok) and then save it:
/usr/local/lib

Close the file and run the following command to configure the library:

sudo ldconfig

OR we can alternatively run the command


  export LD_LIBRARY_PATH=/usr/local/lib

Open your .bashrc file and add the following:

sudo gedit /etc/bash.bashrc

append the following at the end of the file -

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

Save and close the file and reboot the system
Installation is now complete.

No comments:

Post a Comment