#include "stdafx.h" #include "cv.h" #include "highgui.h" #pragma comment (lib, "cv210d.lib") #pragma comment (lib, "cvaux210d.lib") #pragma comment (lib, "cxcore210d.lib") #pragma comment (lib, "highgui210d.lib") void cvText(IplImage* img, const char* text, int x, int y) { CvFont font; double hscale = 1.0; double vscale = 1.0; int linewidth = 2; cvInitFont(&font,CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC,hscale,vscale,0,linewidth); CvScalar textColor =cvScalar(0,255,255); CvPoint textPos =cvPoint(x, y); cvPutText(img, text, textPos, &font,textColor); } void main() { IplImage* image =cvCreateImage(cvSize(500, 600), 8,3); for (int i =0; i <image->width; i++) { for (int j =0; j <image->height; j++) { ((uchar*)(image->imageData +image->widthStep *j))[i *3] =0; ((uchar*)(image->imageData +image->widthStep *j))[i *3 +1] =0; ((uchar*)(image->imageData +image->widthStep *j))[i *3 +2] =0; } } int x1 =35; int y1 =40; cvText(image, "/(35,40/)",35,40); int x2 =122; int y2 =230; cvText(image, "/(122,230/)",122,230); cvLine(image,cvPoint(35,40),cvPoint(122,230),cvScalar(255,255,0),2); cvNamedWindow("window",1); cvShowImage("window",image); cvWaitKey(0); cvReleaseImage(ℑ); }