[vc_row][vc_column][vc_column_text]UPDATE THE REPOSITORIES

The first step that we should do, is make an update of our repositories, so go and open the terminal and execute the follow commands.

sudo apt-get update 
sudo apt-get upgrade

REQUIRED PACKAGES:

  • GCC 4.4.x or later
  • CMake 2.6 or higher
  • Git
  • GTK+2.x or higher, including headers (libgtk2.0-dev)
  • pkg-config
  • Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy)
  • ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev
  • [optional] libtbb2 libtbb-dev
  • [optional] libdc1394 2.x
  • [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev, libdc1394-22-dev

INSTALLING REQUIRED PACKAGES

Type the fllowing commands on console.

sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev  libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-dev yasm 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

DOWNLOAD OPENCV

We can download doing click on the following link  https://github.com/opencv/opencv/archive/2.4.13.6.zip. or executing the next line on console.

wget https://github.com/opencv/opencv/archive/2.4.13.6.zip

UNCOMPRESS , COMPILE AND INSTALL OPENCV

Once downloaded  OPENCV the next step is uncompress the .ZIP , u can do it by two ways : terminal or user interface.

by the terminal:

unzip opencv-2.4.13.6.zip  -d ./opencv-2.4.13

Be sure to be in OPENCV file.

cd opencv-2.4.13.6

For make the configuration by ccmake:

mkdir build

Go to directory  “build”

cd build

Make a opencv configuration with flags..

cmake -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 

sudo make install

sudo reboot

after rebooting the computer open the console and execute “sudo ldconfig

TEST OPENCV

Now the most interesting part is this , enjoy :

cd 
mkdir showImage
cd showImage
wget http://104.236.119.198:8000/FIRST_TUTORIAL/mujer_maravilla.jpg

The next example we are going to use C++.

nano main.cpp

 

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
    if( argc != 2)
    {
     cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
     return -1;
    }

    Mat image;
    image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file

    if(! image.data )                              // Check for invalid input
    {
        cout <<  "Could not open or find the image" << std::endl ;
        return -1;
    }

    namedWindow( "Mujer Maravilla", WINDOW_AUTOSIZE );// Create a window for display.
    imshow( "Mujer Maravilla", image );                   // Show our image inside it.

    waitKey(0);                                          // Wait for a keystroke in the window
    return 0;
}

 

Compile and run the program.

g++ main.cpp -o mujermaravilla `pkg-config --cflags --libs opencv`
./mujermaravilla mujer_maravilla.jpg

And the result is :

 

Reference links:

http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html[/vc_column_text][/vc_column][/vc_row]