How to setup OpenCV in Ubuntu

Posted By : Manu Gupta | 04-May-2016

In this blog i will guide you through the process of setting openCV on your linux machine.Open cv is open source computer vision library of programming functions which is very helpful in case you want to play with your images .

 

First of all what we have to do is get the things upto date

 

 

  1. Open your terminal and write this command to update
                            sudo apt-get uodate && sudo apt-get upgrade
                        
  2. After that install the dependencies which will later help us in compiling the openCV library
                            sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev
                        
  3. Now download the current stable version of openCV. For my project i was required of openCV-2.4.5. You can directly download the below mentioned command and remmember the path where you have downloded it.
                            wget https://github.com/Itseez/opencv/archive/2.4.5.tar.gz
                        
  4. Untar the tar file
                            tar -xvf 2.4.5.tar.gz
                        
  5. Now after this we have to make a cmake file for that what we have to do is open the opensc-2.4.5 folder and create a new folder called build.
                            mkdir build
                            cd build
                        
  6. Now all the steps are required to compile the openCV
                            cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local
                                  -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON
                                  -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON
                                  -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
                        
                            make -j4
                        
    This is going to take some time so please be patient
                            sudo make install
                        
  7. Now what we have to do is just config the opencv
                            sudo ldconfig  
                        

 

After this is your opencv compiled and installed, you are ready to use it with any project. KUDOS

 

Thanks

 

For any further queries feel free to contact.

 

About Author

Author Image
Manu Gupta

Manu is a Native iOS (Swift) and Titanium lead developer . Manu has good experience working with Swift and Alloy framework as well. He loves watching movies and travelling.

Request for Proposal

Name is required

Comment is required

Sending message..