You are on page 1of 1

// show_image.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"
#include "cv.h"
#include "highgui.h"

int _tmain(int argc, _TCHAR* argv[])


{
IplImage *image = 0;
image = cvLoadImage( "C:/Program Files/OpenCV/samples/c/2.jpg", 1 );
if( image )
{
cvNamedWindow( "Show", 1 );
cvShowImage( "Show", image );
printf( "Press any key to exit\n");
cvWaitKey(0);
cvDestroyWindow("result");
}
else
fprintf( stderr, "Error reading image\n" );
return 0;
}

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

int main(int argc, char** argv)


{
IplImage *img = cvLoadImage("2.jpg", CV_LOAD_IMAGE_COLOR);

/* initialize font and add text */


CvFont font;
cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0, 0, 1, CV_AA);
cvPutText(img, "Hello World!", cvPoint(10, 130), &font,
cvScalar(255, 255, 255, 0));

/* display the image */


cvNamedWindow("image", CV_WINDOW_AUTOSIZE);
cvShowImage("image", img);
cvWaitKey(0);
cvDestroyWindow("image");
cvReleaseImage( &img );

return 0;
}

You might also like