OpenCV Hello World

      No Comments on OpenCV Hello World

Here is the Hello World example code for OpenCV. This simple example creates a image called output, then the text “Hello World” is added to the image.

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

int _tmain(int argc, _TCHAR* argv[])
{
	// create image
	IplImage* output = cvCreateImage(cvSize(400, 200), 8, 3);
	
	// create font and add text to the image
	CvFont font;
    cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 1,1,0,1,8);
	cvPutText(output, "Hello World", cvPoint(100,100), &font, cvScalar(255,255,0));
	
	// display image
	cvNamedWindow("Output", CV_WINDOW_AUTOSIZE);
	cvShowImage("Output", output);

	// wait for user
	cvWaitKey(0);

	// garbage collection	
	cvReleaseImage(&output);
	cvDestroyWindow("Output");
	
	return 0;
}

Hello World output image

Leave a Reply

Your email address will not be published. Required fields are marked *