Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to compile basic opencv program in C++ in ubuntu

I have installed opencv in ubuntu 12.04. I have written a basic program in c++. How to compile this basic program in C++ using opencv libraries.

include <cv.h>

include <highgui.h>

int main(){

Mat image;
image = imread("google.jpg", CV_LOAD_IMAGE_UNCHANGED);   // Read the file

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

namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image );                   // Show our image inside it.

waitKey(0);   

  return 0;

}

How to compile basic opencv program in C++ in ubuntu

I have installed opencv in ubuntu 12.04. I have written a basic program in c++. How to compile this basic program in C++ using opencv libraries.

include <cv.h>

include <highgui.h>

int main(){

#include <cv.h>
#include <highgui.h>


int main(){

    Mat image;
 image = imread("google.jpg", CV_LOAD_IMAGE_UNCHANGED);   // Read the file

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

 namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
 imshow( "Display window", image );                   // Show our image inside it.

 waitKey(0);   

   return 0;
}

}