Chf.h #ifndef _CUSTOM_HEADER_FILES_ #define _CUSTOM_HEADER_FILES_ //所需头文件 #include <cv.h> #include <highgui.h> #include <stdio.h> #include <stdlib.h> #include <windows.h> #include <mmsystem.h> //音乐 / //函数声明 void KeboardInit(CvScalar Color); void onMouse(int event,int x,int y,int flags,void* param ); void KeyEvent(int tag); void paintRectanguleAndcircle(int x1,int y1,int x2,int y2,char* ch,CvScalar Color); // //键盘字符 char str1[15][10]={"/`","1","2","3","4","5","6","7","8","9","0","-/_","=/+","backspace"}; char str2[15][10]={ "Tab", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P","/[//{","/]//}","/|"}; char str3[15][10]={"caps lock","A","S","D","F","G","H","J","K","L","://;","/"//'","enter"}; char str4[15][10]={"shift","Z","X","C","V","B","N","M","<//,",">/.","?//","up","shift",}; char str5[15][10]={"ctrl","","","alt","","alt","","left","down","right"}; // //参数,全局变量 CvScalar Close_Window_Color ,Color,Color1, Color2, Color3, Color4; CvPoint VertexOne,VertexThree; //矩形点 int Thickness; int Shift; CvPoint CircleCenter; // 圆心 int Radius =10; //半径 double Scale; // 字的大小 CvPoint TextPosition1; CvFont Font1; CvCapture *capture; IplImage *frame; char ch; unsigned char uch; //用来表示十六进制数,用于特殊键的传值 // #include"KeyboardInit.cpp" #include"KeyEvent.cpp" /** 初始化键盘,界面处理 image默认大小为 长640,宽480 键盘每行,每格之间的间隔为5 (x1,y1)表示 VertexOne (x2,y2)表示 VertexThree */ /* void KeboardInit(CvScalar _Color) { // 第一行 int x1=2,y1=440,x2=42,y2=470; for(int i =0;i<=13;i++){ paintRectanguleAndcircle(x1,y1,x2,y2,str1[i],Color); if(12==i) //backspace {x1=x2+5; x2+=78;} else { x1=x2+5; x2=x1+38; } } //第二行 y1-=35;y2-=35;x1=2;x2=58; for( i = 0;i<=13;i++){ paintRectanguleAndcircle(x1,y1,x2,y2,str2[i],Color); if(i==12) //'/' { x1+=43 ;x2+=62 ;} else { x1=x2+5; x2=x1+38;} } //第三行 y1-=35;y2-=35;x1=2;x2=68; for( i= 0;i<=12;i++){ paintRectanguleAndcircle(x1,y1,x2,y2,str3[i],Color); if(i==11) //enter { x1+=43 ;x2+=95 ;} else { x1=x2+5; x2=x1+38;} } //第四行 y1-=35;y2-=35;x1=2;x2=95; for( i= 0;i<=13;i++){ paintRectanguleAndcircle(x1,y1,x2,y2,str4[i],Color); if(i==11) //left_shift { x1+=43 ;x2+=68;} else { x1=x2+5; x2=x1+38;} } //第五行 y1-=35;y2-=35;x1=2;x2=58; for( i= 0;i<=9;i++){ paintRectanguleAndcircle(x1,y1,x2,y2,str5[i],Color); if(i==3) //space { x1+=43 ;x2+=210;} else { x1=x2+5; x2=x1+38; } } //black circle CircleCenter=cvPoint(30,280); Color1=CV_RGB(0,0,0); cvCircle(frame,CircleCenter,Radius,Color1,Thickness,CV_AA,Shift); //white circle CircleCenter=cvPoint(60,280); Color2=CV_RGB(255,255,255); cvCircle(frame,CircleCenter,Radius,Color2,Thickness,CV_AA,Shift); //yellow circle CircleCenter=cvPoint(90,280); Color3=CV_RGB(255,255,0); cvCircle(frame,CircleCenter,Radius,Color3,Thickness,CV_AA,Shift); //green circle CircleCenter=cvPoint(120,280); Color4=CV_RGB(0,125