Saturday 10 October 2015

How to install OpenCV in Ubuntu 14.04

     Today, I am going to discuss installation of one of the very crucial and important software tool OpenCV {Open Computer Vision}. Installation of OpenCV on Windows is very easy as compared to Linux and that too on Ubuntu 14.04.
     Lets start the discussion. First of all, do remember that Ubuntu 14.04 supports 3.0.0 version of OpenCV. So it may happen that when you try to install OpenCV on your Machine you may get latest version of OpenCV.

Follow these steps to get rid of all problems and ease the installation experience.

1. Check that your machine has following packages installed or not. 

     a. Gcc
     b. CMake
     c. git
     d. gtk
     e. pkg-config
     f. Python

You can check particular package is installed or not by using following terminal commands.
For Debian or Ubuntu Based Linux :
$dpkg -l <package-Name>

For example:
$ dpkg -l gcc

For RPM based Linux such as Redhat or Fedora or CentOS or SUSE:
$rpm -qi <package-Name>

For example:
$ rpm -qi gcc

Install above mentioned packages before proceeding. Use following commands,
For Debian or Ubuntu Based Linux :
$sudo apt-get install <package-Name> 

For RPM based Linux such as Redhat or Fedora or CentOS or SUSE:
$ sudo yum install <package-Name>

2. Download Compatible version of OpenCV (Version 3.0) for Ubuntu 14.04. Find suitable link to download OpenCV 3.0. You may refer following link
Download OpenCV 3.0

3. Unzip the downloaded file. 
     a. Go to OpenCV folder after extracting it.
     b. Create a directory to install OpenCV in your machine.
$ mkdir release

     c. Go to "release" directory.
$ cd release

     d. Type following commands in terminal (Notice, last two dots with one space in between. These are important)

     e. Now proceed with following commands, "make" commands requires a little bit time (Around 45 minutes) to get complete.
$ make
$ sudo make install

4. Setup Environment variables. Edit "/etc/profile" in your favorite editor as follows & save before closing it,
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH=/usr/local/lib

Type the following command on terminal to take affect our above changes. Again Notice the space between 'dot' & "/etc/profile"
$ . /etc/profile

5. We are done with the installation process. Now is the time to check our installation is correct or not.
     a. Go to your OpenCV folder. Go to "Samples" directory. Then "C" directory.
$ cd path/samples/c
$ sh
$ ./facedetect lena.jpg

If you get an image with a circle drawn around the face present in the image then your OpenCV installation is successfully completed. You can start using it.

==>Posted By Yogesh B. Desai

Previous Post: How to install OpenCV in Fedora 20

Next Post: How to install CUDA in Ubuntu 14.04

You are Visitor Number:
web counter free

No comments:

Post a Comment