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

][j]=0。 //初始化,使得坐标序列中的点皆为空点 mytime=0。 for(i=0。 i100。 i++){ mypoint[i].x=1。 mypoint[i].y=1。 } mytime=0。 curvalue=1。 mytezheng=(TEZHENG *)malloc(sizeof(TEZHENG))。 mytezhengvalue=1。 mytezhenglenth=0。 mytezhenglenth1=0。 for(i=0。 i15。 i++) mytezhengVHDerection[i]=1。 14 mytezhengdecon=0。 //打开保存模板特征量的文件 if((,CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite)==NULL){ AfxMessageBox(打开文件失败, \n您最好退出程序 )。 } } 创建主界面程序 void CPatternView::OnDraw(CDC* pDC) { CPatternDoc* pDoc = GetDocument()。 ASSERT_VALID(pDoc)。 /*ASSERT_VALID 是一个断定宏,如果 pDoc 为NULL就不继续运行 */ // TODO: add draw code for native data here //Erase the background // 创建一个面色刷 CBrush Brush (RGB (128, 0 , 0) )。 /*CBrush是封装了 Windows 图形设备接口( GDI)中画刷的 MFC 类,用于构造 CBrush 对象,然后传给需要画刷的CDC 成员函数 */ CBrush* pOldBrush = pDCSelectObject (amp。 Brush)。 //选择刷到设备上下文 // Get the area that needs to be erased(擦除) . CRect rcClip。 //CRect 从 tagRECT结构派生而来 pDCGetClipBox (amp。 rcClip)。 /*该函数得到一个能够完整包含当前可见区域的最小矩形的大小 */ //Paint the area. pDC PatBlt ( , , ( ) , ( ) , PATCOPY )。 //使用当前选入指定设备环境中的刷子绘制给定的矩形区域 15 pDCSelectObject (pOldBrush )。 //取消选择刷出设备上下文 //三个模拟位图按钮 CBitmap bitmapstudy,bitmaprecognize,bitmapclear。 /*类 CBitmap 封装了Windows 图形设备接口( GDI)中的位图 */ CDC dcMemory1,dcMemory2,dcMemory3。 /*通过 CDC 对象的成员函数进行所有的绘图 */ (IDB_BITMAP_STUDY)。 /*从模块的可执行文件中加载IDB_BITMAP_STUDY 位图资源 */ (pDC)。 /*创建一个与 PDC 兼容的内存设备上下文环境( DC) */ (amp。 bitmapstudy)。 /*选择 bitmapstudy 到 dcMemory1 的上下文环境中 */ pDCBitBlt(220, 20, 50, 20, 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)。 16 //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。 17 } 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,s。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。