Sunday 4 October 2015

How to Install OpenCV in Fedora 20

Fedora20-OpenCV

     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 Fedora 20.
     Lets start the discussion. First of all, do remember that Fedora 20 supports 2.4.* 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 {For Fedora, gtk2-devel & gtk3-devel are the packages to be installed}
     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 2.4.11) for Fedora 20. Find suitable link to download OpenCV 2.4.11. You may refer following link
Download OpenCV 2.4.11

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).

Lets say your opencv folder is present in "/root/opencv-2.4.11" (Same as "/home/opencv-2.4.11"),  then  you can replace those double dots by "/root/opencv-2.4.11/" to install opencv. 

Note: One need to specify the location or path, where the opencv-2.4.11 folder is located.


$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON . .

     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 build_all.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 : Open Source Home Page

Next Post : How to install OpenCV in Ubuntu 14.04


You are Visitor Number:
conter12

1 comment:

  1. Thank you for the important info! What is the meaning of ". ." in the configuration step? Please explain.

    ReplyDelete