曾经做过,没想到这次再次写这篇代码却用了这么久的时间。这回我要记住他。
1 #include"cv.h" 2 #include"highgui.h" 3 4 int main() 5 { 6 IplImage* Plane = cvCreateImage(cvSize(500,500),8,3); 7 cvAddS(Plane,cvScalar(100,0,200),Plane); 8 cvCircle(Plane,cvPoint(250,250),100,cvScalar(0,180,0),2); 9 cvPutText(Plane,"12",cvPoint(236,145),&cvFont(1,1),cvScalar(50,150,10)); 10 cvPutText(Plane, "3", cvPoint(355, 250), &cvFont(1, 1), cvScalar(50, 150, 10)); 11 cvPutText(Plane, "4", cvPoint(345, 300), &cvFont(1, 1), cvScalar(50, 150, 10)); 12 cvPutText(Plane, "5", cvPoint(315, 340), &cvFont(1, 1), cvScalar(50, 150, 10)); 13 cvPutText(Plane, "6", cvPoint(250, 365), &cvFont(1, 1), cvScalar(50, 150, 10)); 14 cvPutText(Plane, "7", cvPoint(185, 345), &cvFont(1, 1), cvScalar(50, 150, 10)); 15 cvPutText(Plane, "8", cvPoint(150, 305), &cvFont(1, 1), cvScalar(50, 150, 10)); 16 17 cvPutText(Plane, "9", cvPoint(135, 250), &cvFont(1, 1), cvScalar(50, 150, 10)); 18 cvPutText(Plane, "10", cvPoint(140, 200), &cvFont(1, 1), cvScalar(50, 150, 10)); 19 cvPutText(Plane, "11", cvPoint(175, 165), &cvFont(1, 1), cvScalar(50, 150, 10)); 20 cvPutText(Plane, "1", cvPoint(300, 160), &cvFont(1, 1), cvScalar(50, 150, 10)); 21 cvPutText(Plane, "2", cvPoint(340, 195), &cvFont(1, 1), cvScalar(50, 150, 10)); 22 cvCircle(Plane,cvPoint(250,250),3,cvScalarAll(50),4); 23 IplImage* img = cvCreateImage(cvGetSize(Plane),8,3); 24 double angle = 0; 25 int x = 250; 26 int y=150; 27 int dx = 0; 28 int dy = 0; 29 30 while (true) 31 { 32 cvCopy(Plane,img); 33 dy = 100 * cos(angle); 34 dx = 100 * sin(angle); 35 angle +=0.0515; 36 cvLine(img,cvPoint(250,250),cvPoint(250+dx,250-dy),cvScalar(100,90,0),1); 37 cvShowImage("Clock", img); 38 if (cvWaitKey(1000) == 27) 39 { 40 if (cvWaitKey(0) == 27)continue; 41 } 42 } 43 44 cvWaitKey(0); 45 return 0; 46 } 47 int ToA(int x1,int y1, int x2,int y2,int r) 48 { 49 return 0; 50 }
时间: 2024-10-10 03:06:21