- #include <cv.h>
- #include <highgui.h>
- #include <windows.h>
- int main(int argc, char* argv[])
- {
- // LOAD IMAGE color
- IplImage *src = cvLoadImage("e://lena.jpg", CV_LOAD_IMAGE_COLOR);
- // create windows
- cvNamedWindow("image", CV_WINDOW_AUTOSIZE);
- //the font variable
- CvFont font;
- double hScale=1;
- double vScale=1;
- int lineWidth=2;// 相当于写字的线条
- TCHAR showMsg[]="hello image!";
- // 初始化字体
- cvInitFont(&font,CV_FONT_HERSHEY_SIMPLEX|CV_FONT_ITALIC, hScale,vScale,0,lineWidth);//初始化字体,准备写到图片上的
- // cvPoint 为起笔的x,y坐标
- cvPutText(src,showMsg,cvPoint(200,200),&font,CV_RGB(255,0,0));//在图片中输出字符
- // show image
- cvShowImage("image", src);
- cvWaitKey(0);
- cvDestroyWindow("image");
- cvReleaseImage(&src);
- printf("Hello World!/n");
- return 0;
- }