基于vc手写数字识别程序设计(编辑修改稿)内容摘要:

, amp。 dcMemory1, 0, 0, SRCCOPY)。 /*对amp。 dcMemory1中的像素进行位块转换,以传送到目标设备环境*/ (IDB_BITMAP_RECOGNIZE)。 (pDC)。 (amp。 bitmaprecognize)。 pDCBitBlt(220, 80, 50, 20, amp。 dcMemory2, 0, 0, SRCCOPY)。 (IDB_BITMAP_CLEAR)。 (pDC)。 (amp。 bitmapclear)。 pDCBitBlt(220, 140, 50, 20, amp。 dcMemory3, 0, 0, SRCCOPY)。 //画板 CBrush BrushBoard (RGB (255, 255 , 255) )。 // Select the brush into the device context . pOldBrush = pDCSelectObject (amp。 BrushBoard)。 //Paint the area. pDC PatBlt (8,8,176,240, PATCOPY )。 //Unselect brush out of device context pDCSelectObject (pOldBrush )。 pDCSetTextColor(RGB(255,255,255))。 //设置当前环境(HDC)的字体颜色pDCSetTextAlign(TA_CENTER|TA_TOP)。 //指定设备环境设置文字对齐标志pDCSetBkMode(TRANSPARENT)。 /*TRANSPARENT是使用透明的输出,也就是文字的背景是不改变的*/}学习程序void CPatternView::OnStudy(void){//输入数字值的对话框 InputDialog inputdlg。 ()。 //定位当前文件指针到文件开头 int nFileSize=()。 //获取文件长度 int i=nFileSize/sizeof(TEZHENG)。 TEZHENG *temp。 temp=(TEZHENG *)malloc(sizeof(TEZHENG))。 //计算当前画板中数字的特征值 GetTeZheng()。 //首先判断当前的数字类型是否已经在模板中 for(int j=0。 ji。 j++){ ((void *)temp,sizeof(TEZHENG))。 //从文件cf的当前位置读数据 for(int k=0。 k15。 k++){ if(tempVHDerection[k]!=mytezhengVHDerection[k]) //判断水平特征 break。 } if((k==15)amp。 amp。 (tempdecon==mytezhengdecon)amp。 amp。 (templenfirst==mytezhenglenfirst)amp。 amp。 (templenth1==mytezhenglenth1)amp。 amp。 (templenth==mytezhenglenth)amp。 amp。 (templenend==mytezhenglenend)){ char s[20]。 sprintf(s,您输入的是:%d,数据已有,tempvalue)。 AfxMessageBox(s)。 break。 } } //说明该数字类型不在模板中 if(j==i){ if(()==IDOK){ //判断数字输入对话框中的两个数字是否相同 if(!=){ AfxMessageBox(您的输入有误,\n请重新输入)。 } //相同,则将新的数字类型写入模板文件中 else{ GetTeZheng()。 try{mytezhengvalue=。 ()。 //定位当前文件指针到文件尾(amp。 mytezhengvalue,sizeof(signed char))。 //将文件数据写入当前文件位置(mytezhengVHDerection,sizeof(signed char)*15)。 (amp。 mytezhenglenth1,sizeof(signed char))。 (amp。 mytezhenglenth,sizeof(signed char))。 (amp。 mytezhengdecon,sizeof(signed char))。 (amp。 mytezhenglenfirst,sizeof(signed char))。 (amp。 mytezhenglenend,sizeof(signed char))。 } catch(CFileException *e){ //Alert user to error eDelete()。 }//end trycatch }//end ifelse }//end if }//end ifreturn。 }识别程序void CPatternView::OnRecognize(void){ ()。 int nFileSize=()。 int i=nFileSize/sizeof(TEZHENG)。 TEZHENG *temp。 temp=(TEZHENG *)malloc(sizeof(TEZHENG))。 //计算特征值 GetTeZheng()。 //在模板文件中寻找,是否有与当前特征值相同的 for(int j=0。 ji。 j++){ ((void *)temp,sizeof(TEZHENG))。 for(int k=0。 k15。 k++){ if(tempVHDerection[k]!=mytezhengVHDerection[k]) break。 } //找到识别结果if((k==15)amp。 amp。 (tempdecon==mytezhengdecon)amp。 amp。 (templenfirst==mytezhenglenfirst)amp。 amp。 (templenth1==mytezhenglenth1)amp。 amp。 (templenth==mytezhenglenth)amp。 amp。 (templenend==mytezhenglenend)){ char s[20]。 sprintf(s,您输入的是:%d,tempvalue)。 Afx。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。