OpenCV : Displaying an Image

Here is a Sample application to display an image.


Download the Project folder and the source code.



//______________________________________________________________________________________
// OpenCV Demo Program
// Author: Bharath Prabhuswamy
//______________________________________________________________________________________
//______________________________________________________________________________________

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

int main()
{
 
    cvNamedWindow( "image", CV_WINDOW_AUTOSIZE);

 /* Load an Image from the disk */
 IplImage* img  = cvLoadImage("things.jpg");
 
 /* Always check if the program can find the file */
 if( !img )
  return -1;
 
 /* Display the image in the window named "image" */
    cvShowImage( "image", img );
    cvWaitKey(0);

 /* Clean up memory */
    cvDestroyWindow( "image" );
    cvReleaseImage( &img );
    return 0;
}