Like us on google+

Saturday, 8 February 2014

Widgets

Installing OpenCV In Ubuntu and running the first program in C++.

METHOD 1:

First install the synaptic package manager from the ubuntu software center.



Then in the search bar just type opencv and tick the required packages and install them.Below is just the screenshot of that.

After doing the above step you are almost done!!!!!...

Next step is to run the sample code to make sure that everything is installed correctly.



#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:dsplay_image ImageToLoadAndDisplay";
     
return -1;
    
}

    Mat image;
    
image = imread(argv[1], CV_LOAD_IMAGE_COLOR);

    if(! image.data )                            
    {
       cout <<  "Could not open or find the img";
         
return -1;
    }

    namedWindow( "Display window", WINDOW_AUTOSIZE );
     
imshow( "Display window", image );                  

    waitKey(0);                                          
    
return 0;

}

While compiling the program use the below command:

g++ filename.cpp `pkg-config --cflags --libs opencv`

run using:./a.out imagename.image format

ex:./a.out lena.jpg

-----------------------------------------------------METHOD 2:
Directly download opencv from ubuntu software center.
Search for opencv in the search bar and install easily.

Then copy the above program which i had mentioned in the method 1 and you are  done.......!!
---------------------------------------------------------------------------------

SHARE THIS POST   

  • Facebook
  • Twitter
  • Myspace
  • Google Buzz
  • Reddit
  • Stumnleupon
  • Delicious
  • Digg
  • Technorati
About us:
Hi guys Sandesh and Rajesh here ... studing engineering in PESIT started this blog as a google contest and also we love blogging ...Hope u like it ...Encourage us by liking us on g+... Any queries dont hesitate to ask Read More →

0 comments: