- // patternDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "pattern.h"
- #include "patternDlg.h"
- #include "Afxwin.h"
- #include "Afxdlgs.h"
- #include "winuser.h"
- #include "Store.h"
- #include <STDIO.H>
- //#define _MBCS
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #include<WINDOWS.H>
- #include<MATH.H>
- #define Startx 30
- #define Starty 190
- #define wid 192
- #define lon 192
- #define yu 3 //2 area
- #define yu1 5 //dou dong
- #define yu2 4
- int num,Time;
- int xmax,ymax,xmin,ymin; //随时纪录书写过程中的书写范围
- //存储书写笔迹的坐标序列,按笔划存储,每个笔划最多300个点
- //每个字最多15个笔划
- struct
- {
- int x;
- int y;
- }store[15][300];
- //备份的序列
- struct
- {
- int x;
- int y;
- }storeback[15][300];
- struct
- {
- int total;//总的笔划数
- char zifu[2];//代表字符
- int dian[15];//每个笔划的点数
- struct{
- int relate;//相对前点特征
- int region;//全局位置特征
- int arc;//过渡带特征
- }detail[15][20];//15个笔划上的特征点,每个笔划20个特征点
- }tez[2002];
- struct
- {
- int total;
- int dian[15];
- struct
- {
- int relate;
- int region;
- int arc;
- }detail[15][20];
- }test;//意义同上,为测试点的结构
- int queue[50];
- int queue1[40];
- int zong;
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- // Dialog Data
- //{ {AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
- // ClassWizard generated virtual function overrides
- //{ {AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
- // Implementation
- protected:
- //{ {AFX_MSG(CAboutDlg)
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{ {AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{ {AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{ {AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CPatternDlg dialog
- CPatternDlg::CPatternDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CPatternDlg::IDD, pParent)
- {
- //{ {AFX_DATA_INIT(CPatternDlg)
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- void CPatternDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{ {AFX_DATA_MAP(CPatternDlg)
- DDX_Control(pDX, IDC_EDIT2, m_edit2);
- DDX_Control(pDX, IDC_EDIT1, m_edit1);
- DDX_Control(pDX, IDC_BUTTON4, m_escape);
- DDX_Control(pDX, IDC_BUTTON3, m_clear);
- DDX_Control(pDX, IDC_BUTTON1, m_recog);
- DDX_Control(pDX, IDC_BUTTON2, m_study);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CPatternDlg, CDialog)
- //{ {AFX_MSG_MAP(CPatternDlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_BUTTON4, OnEsp)
- ON_BN_CLICKED(IDC_BUTTON1, OnRecog)
- ON_WM_MOUSEMOVE()
- ON_BN_CLICKED(IDC_BUTTON3, OnClear)
- ON_BN_CLICKED(IDC_BUTTON2, OnStudy)
- ON_WM_LBUTTONUP()
- ON_WM_LBUTTONDOWN()
- ON_COMMAND(ID_EXIT_MENU, OnExitMenu)
- ON_COMMAND(ID_ABOUT_MENU, OnAboutMenu)
- ON_COMMAND(ID_SAVE_MENU, OnSaveMenu1)
- ON_COMMAND(ID_OPEN_MENU, OnOpenMenu)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CPatternDlg message handlers
- BOOL CPatternDlg::OnInitDialog()
- {
- CFile cf;
- CDialog::OnInitDialog();
- mouseDown=0;
- int i,j,k;
- //将每个笔划上坐标初始化为空
- for(i=0;i<15;i++)
- {
- for(j=0;j<300;j++)
- {
- store[i][j].x=-1;
- store[i][j].y=-1;
- }
- }
- for(i=0;i<15;i++)
- {
- for(j=0;j<300;j++)
- {
- storeback[i][j].x=-1;
- storeback[i][j].y=-1;
- }
- }
- for(i=0;i<10;i++)
- {
- tez[i].total=-1;
- for(j=0;j<15;j++)
- tez[i].dian[j]=-1;
- for(j=0;j<15;j++)
- {
- for(k=0;k<20;k++)
- {
- tez[i].detail[j][k].relate=0;
- tez[i].detail[j][k].arc=0;
- tez[i].detail[j][k].region=0;
- }
- }
- }
- Time=0;
- num=0;
- zong=-1;//tez下标
- xmax=0;
- ymax=0;
- xmin=31;
- ymin=31;
- for(i=0;i<50;i++)
- queue[i]=-1;
- for(i=0;i<40;i++)
- queue1[i]=-1;
- test.total=-1;
- for(j=0;j<15;j++)
- test.dian[j]=-1;
- for(j=0;j<15;j++)
- {
- for(k=0;k<20;k++)
- {
- test.detail[j][k].relate=0;
- test.detail[j][k].arc=0;
- test.detail[j][k].region=0;
- }
- }
- // Add "About..." menu item to system menu.
- // IDM_ABOUTBOX must be in the system command range.
- ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
- ASSERT(IDM_ABOUTBOX < 0xF000);
- CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
- CString strAboutMenu;
- strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty())
- {
- pSysMenu->AppendMenu(MF_SEPARATOR);
- pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
- }
- }
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
- // TODO: Add extra initialization here
- if(cf.Open("mydata.dat",CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite)==NULL){
- AfxMessageBox(
识别简单的数字,字母的手写识别框架
最新推荐文章于 2024-01-18 08:58:16 发布
