dipView.h
上传用户:cdscwht
上传日期:2022-07-27
资源大小:264k
文件大小:7k
源码类别:

图形/文字识别

开发平台:

Visual Basic

  1. // dipView.h : interface of the CDipView class
  2. //
  3. /////////////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_DIPVIEW_H__C986E395_5D00_49E6_8CC4_C66489A44EC0__INCLUDED_)
  5. #define AFX_DIPVIEW_H__C986E395_5D00_49E6_8CC4_C66489A44EC0__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include "Mdlg.h"
  10. #include "digitclass.h"
  11. #include "AnnBP.h" // Added by ClassView
  12. #include "Training.h" // Added by ClassView
  13. class CDipView : public CView
  14. {
  15. //data
  16. public:
  17. int a;
  18. int b;
  19. CBitmap* m_pBmp;
  20. CDC  * m_pMemDC; //内存DC
  21. CBitmap  * m_pBitmap,*mymap; //背景图像,当前数据的内存图像
  22. bool IsNewFile,IsNewBitmap; //数据是否更新,内存图像是否更新
  23. CList <sample,sample> hanList;
  24. CList <sample,sample> charList;
  25. CList <sample,sample> numList;
  26. protected: // create from serialization only
  27. CDipView();
  28. DECLARE_DYNCREATE(CDipView)
  29. // Attributes
  30. public:
  31. CDipDoc* GetDocument();
  32. // Operations
  33. public:
  34. // Overrides
  35. // ClassWizard generated virtual function overrides
  36. //{{AFX_VIRTUAL(CDipView)
  37. public:
  38. virtual void OnDraw(CDC* pDC);  // overridden to draw this view
  39. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  40. virtual void OnInitialUpdate();
  41. protected:
  42. virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
  43. virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
  44. virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
  45. //}}AFX_VIRTUAL
  46. // Implementation
  47. public:
  48. BYTE* img;
  49. void ChageStatuBar(char * fmt);
  50. virtual ~CDipView();
  51. #ifdef _DEBUG
  52. virtual void AssertValid() const;
  53. virtual void Dump(CDumpContext& dc) const;
  54. #endif
  55. protected:
  56. // Generated message map functions
  57. protected:
  58. //{{AFX_MSG(CDipView)
  59. afx_msg void OnFileOpen();
  60. afx_msg void OnPaint();
  61. afx_msg void OnFileSave();
  62. afx_msg void Onreopen();
  63. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  64. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  65. afx_msg void OnLine();
  66. afx_msg void Onrhua();
  67. afx_msg void Onphua();
  68. afx_msg void Onfse();
  69. afx_msg void Onfz();
  70. afx_msg void OnMoHu();
  71. afx_msg void OnSuoXiao();
  72. afx_msg void OnForHandle();
  73. afx_msg void OnHSearch();
  74. afx_msg void OnBanlance();
  75. afx_msg void OnSubVertical();
  76. afx_msg void OnSubHorizontal();
  77. afx_msg void OnMidValue();
  78. afx_msg void OnAverage();
  79. afx_msg void OnBool();
  80. afx_msg void OnChoose();
  81. afx_msg void OnTrainfromvehicle();
  82. afx_msg void OnSave();
  83. afx_msg void OnLoad();
  84. afx_msg void OnChange();
  85. afx_msg void OnTrain();
  86. afx_msg void OnSavebp();
  87. afx_msg void OnReadbp();
  88. //}}AFX_MSG
  89. DECLARE_MESSAGE_MAP()
  90. public:
  91. CTraining* m_pdlg;
  92. CAnnBP char_num_bp;
  93. CAnnBP num_bp;
  94. CAnnBP char_bp;
  95. POSITION char_ConnectPos;
  96. POSITION num_ConnectPos;
  97. POSITION han_ConnectPos;
  98. //分割出的字符数
  99. int CharacterNum;
  100. void ForHandle(BYTE* DisposeImg,int width,int height);
  101. void VFurthLocate(BYTE* DisposeImg,int width,int height);
  102. // 精确定位
  103. void FurtherLocate(CDipDoc *DisposeImg,int width,int height);
  104. int MaxJump(int *JumpNums,int num);
  105. // 计算各伪车牌区的跳变数
  106. int JumpNum(BYTE*DisposeImg,int width,int height);
  107. // 去伪存真
  108. void Choose(CDipDoc *DisposeImg,int width,int height);
  109. afx_msg void OnVSearch();
  110. afx_msg void OnLocate();
  111. // 均衡化图象
  112. void Banlance(BYTE* DisposeImg,int Width,int Height);
  113. // 图象复制
  114. void CopyImg(CDipDoc *SourceImg, BYTE* DestImg, int Width, int Height);
  115. // 水平差分
  116. void HSub(BYTE* DisposeImg, int Width , int Height);
  117. // 选择区域的高度
  118. int* Height;
  119. // 选择区域的起始行
  120. int* TopRow;
  121. // 完成图象车牌区域的定位
  122. void Search(BYTE* DisposeImg, int width , int height);
  123. // 图象复制
  124. void CopyImg(BYTE* SourceImg, BYTE* DestImg, int Width , int Height);
  125. // 标识车牌区域
  126. void Mark(CDipDoc * DisposeImg, int width , int height);
  127. void VSearch(BYTE* DisposeImg, int width, int height);
  128. // 车牌宽度区域值
  129. int* Widths;
  130. // 车牌左边缘
  131. int* Left;
  132. // 纵向差分
  133. void VSub(BYTE* DisposeImg, int Width , int Height);
  134. // 纵向定位
  135. void VMark(CDipDoc* DisposeImg, int width, int height);
  136. // 起始位置的横坐标
  137. int* Rect_X;
  138. // 纵坐标
  139. int* Rect_Y;
  140. // 宽度
  141. int* Rect_W;
  142. // 高度
  143. int* Rect_H;
  144. // 伪车牌区域
  145. void DrawRect(CDipDoc* DisposeImg, int width, int height);
  146. // 可能的区域数
  147. int Rect_Areas;
  148. // 寻找left==255,right==0的列
  149. int FindNextCol_LR(int* HProj, int size, int objectCol);
  150. // 寻找right==255,left==0的列
  151. int FindNextCol_RL(int* HProj, int size, int objectCol);
  152. afx_msg void OnSobel();
  153. afx_msg void OnVSplit();        
  154. // 图像规定化0~100
  155. void GuiYiHua(BYTE* DisposeImg, int width , int height);
  156. // 增强车牌区,削弱背景
  157. void Hance(BYTE* DisposeImg, int width , int height);
  158. afx_msg void OnGuiYiHua();
  159. afx_msg void OnHance();
  160. // 分割出字符
  161. void HProj(BYTE* DisposeImg, int* projArray, int width , int height);
  162. // 寻找波谷
  163. void FindTrough(int* Array, int size);
  164. //剔除部分边框
  165. //void DropLine(BYTE* DisposeImg, int width,int height);
  166. // 精确定位各字符域
  167. void FindCharacter(BYTE* DisposeImg, int width , int height ,int*Array, int size);
  168. //车牌区域再次定位
  169. void VSearchAdvance(BYTE* DisposeImg, int width, int height,int lside);
  170. // 分割字符
  171. void CharacterSplit(int* Array, int size);
  172. //字符区域的矩形表示(相对与原始图象)
  173. struct cRect
  174. {
  175. int x;
  176. int y;
  177. int w;
  178. int h;
  179. };
  180. typedef cRect crect;
  181. crect *cRects;
  182. //字符区域的实际数据保存
  183. struct characetrData
  184. {
  185. BYTE* Img;
  186. int w;
  187. int h;
  188. };
  189. typedef characetrData cData;
  190. cData *cDatas;
  191. struct sample//保存样本的结构体
  192. {
  193. double feature[13];//样本的特征向量
  194. char trueClass[3];//样本所属的真实类别+
  195. int serialnum;//序列号
  196. };
  197. int CDipView::map(char *character);
  198. /* // //读取样本库,传入一个sample类型的数组(从文件里读出的样本数据将放入其中),返回值为样本个数
  199. int LoadCharLib(sample* sa);
  200. // 缩放算法,一律缩放为20*36
  201. void Zoom(BYTE* DisposeImg, int width, int height);
  202. // 二值化算法,二值化为0和1两种值
  203. void BinaryImg(BYTE* DisposeImg, int width , int height);
  204. // Hilditch细化算法
  205. void ThinnerHilditch(void*image, unsigned long lx, unsigned long ly);
  206. // 细化算法
  207. void ThinImage(BYTE* image, int width, int height);
  208. // 获取特征值的函数
  209. void GetFeature(BYTE* image, long width, long height, double* feature, int size);
  210. // 识别函数,第一个参数为LoadCharLib读出的数组,第二个参数为LoadCharLib的返回值(即样本个数),将上面获得的特征值传入第三个参数,返回为识别结果
  211. CString Recognize(sample* sa, int num, double* feature);
  212. // 字符识别
  213. void GetCharacter();*/
  214. afx_msg void OnCharacterRecg();
  215. };
  216. #ifndef _DEBUG  // debug version in dipView.cpp
  217. inline CDipDoc* CDipView::GetDocument()
  218.    { return (CDipDoc*)m_pDocument; }
  219. #endif
  220. /////////////////////////////////////////////////////////////////////////////
  221. //{{AFX_INSERT_LOCATION}}
  222. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  223. #endif // !defined(AFX_DIPVIEW_H__C986E395_5D00_49E6_8CC4_C66489A44EC0__INCLUDED_)