WinCE的手写识别技术的详细介绍
WinCE的手写识别技术的详细介绍
//========================================================================
//TITLE:
// 漫谈WinCE的手写识别技术(二)
//AUTHOR:
// norains
//DATE:
// Thursday 25-January -2007
//Environment:
// EVC4.0 + Standard SDK
//========================================================================
在第一章的时候,已经介绍了识别的一般性过程,对于实际运用来说,是完全可行的;但从便利性角度出发,却不免显得烦琐:每次输入笔画都需留意点阵是否屏幕坐标系,每次读取返回的字符总要分配内存然后获取等等,诸如总总,代码写一次还好,如果多处运用多次编写多方维护,实在不是一件快乐的事情.
而我,最讨厌做复杂又要花费脑筋的东东;所以,为了让自己感觉得写代码是一件快乐的事情,自己又很高兴地将识别过程封装为一个类.至于是否达到简便的效果,不敢祈求大家苟同,只愿自己舒坦即可.
//////////////////////////////////////////////////////////////////////
//Recognizer.h:interfacefortheCRecognizerclass.//
//////////////////////////////////////////////////////////////////////
#ifndefRECOGNIZER_H
#defineRECOGNIZER_H
//===========================================================================
//Includefile
#include"recog.h"
//=====================================================================================
//Choosethebuildtypefortherecognizingfunction
//--------------------------------------------------------------------------
#defineRECOGNIZE_FUNCTION_FROM_DLL
//#defineRECOGNIZE_FUNCTION_FROM_LIB
#ifndefRECOGNIZE_FUNCTION_FROM_LIB
#ifndefRECOGNIZE_FUNCTION_FROM_DLL
#defineRECOGNIZE_FUNCTION_FROM_DLL
#endif
#endif
#ifdefRECOGNIZE_FUNCTION_FROM_DLL
#defineRECOGNIZE_DLL_PATHTEXT("/WINDOWS/hwxcht.dll")
#endif
//=====================================================================================
//-----------------------------------------------------------------------------------
//Thedatatype
//Thescaletypeforthecoordinate
enumScaleType
{
SCALE_APPWND,
SCALE_SCREEN
};
//------------------------------------------------------------------------------
classCRecognizer
{
public:
BOOLInputStroke(POINT*lpPnt,intiCount,ScaleTypescale);
CRecognizer();
virtual~CRecognizer();
intGetCharacter(WCHAR*pWchar,intiCount);
BOOLEndRecognize();
BOOLBeginRecognize();
BOOLInitialize(HWNDhWnd,constRECT*prcWnd,ScaleTypescale);
protected:
HRCm_hrc;
HWXGUIDEm_hwxGuide;
HWNDm_hWndRecog;
ALCm_alc;
#ifdefRECOGNIZE_FUNCTION_FROM_DLL
typedefBOOL(WINAPI*DLL_HWXCONFIG)(void);
typedefHRC(WINAPI*DLL_HWXCREATE)(HRC=NULL);
typedefBOOL(WINAPI*DLL_HWXSETGUIDE)(HRC,HWXGUIDE*);
typedefBOOL(WINAPI*DLL_HWXALCVALID)(HRC,ALC);
typedefBOOL(WINAPI*DLL_HWXALCPRIORITY)(HRC,ALC);
typedefBOOL(WINAPI*DLL_HWXSETCONTEXT)(HRC,WCHAR);
typedefBOOL(WINAPI*DLL_HWXINPUT)(HRC,POINT*,UINT,DWORD);
typedefBOOL(WINAPI*DLL_HWXENDINPUT)(HRC);
typedefBOOL(WINAPI*DLL_HWXPROCESS)(HRC);
typedefINT(WINAPI*DLL_HWXRESULTSAVAILABLE)(HRC);
typedefINT32(WINAPI*DLL_HWXGETRESULTS)(HRC,UINT,UINT,UINT,HWXRESULTS*);
typedefBOOL(WINAPI*DLL_HWXDESTROY)(HRC);
DLL_HWXCONFIGHWXCONFIG;
DLL_HWXCREATEHWXCREATE;
DLL_HWXSETGUIDEHWXSETGUIDE;
DLL_HWXALCVALIDHWXALCVALID;
DLL_HWXALCPRIORITYHWXALCPRIORITY;
DLL_HWXSETCONTEXTHWXSETCONTEXT;
DLL_HWXINPUTHWXINPUT;
DLL_HWXPROCESSHWXPROCESS;
DLL_HWXRESULTSAVAILABLEHWXRESULTSAVAILABLE;
DLL_HWXGETRESULTSHWXGETRESULTS;
DLL_HWXDESTROYHWXDESTROY;
DLL_HWXENDINPUTHWXENDINPUT;
#endif//RECOGNIZE_FUNCTION_FROM_DLL
#ifdefRECOGNIZE_FUNCTION_FROM_LIB
#defineHWXCONFIG(void)HwxConfig(void)
#defineHWXCREATE(hrc)HwxCreate(hrc)
#defineHWXSETGUIDE(hrc,lpGuide)HwxSetGuide(hrc,lpGuide)
#defineHWXALCVALID(hrc,alc)HwxALCValid(hrc,alc)
#defineHWXALCPRIORITY(hrc,alc)HwxALCPriority(hrc,alc)
#defineHWXSETCONTEXT(hrc,wContext)HwxSetContext(hrc,wContext)
#defineHWXINPUT(hrc,lppnt,upoints,timestamp)HwxInput(hrc,lppnt,upoints,timestamp)
#defineHWXPROCESS(hrc)HwxProcess(hrc)
#defineHWXRESULTSAVAILABLE(hrc)HwxResultsAvailable(hrc)
#defineHWXGETRESULTS(hrc,cAlt,iFirst,cBoxRes,rgBoxResults)HwxGetResults(hrc,cAlt,iFirst,cBoxRes,rgBoxResults)
#defineHWXDESTROY(hrc)HwxDestroy(hrc)
#defineHWXENDINPUT(hrc)HwxEndInput(hrc)
#endif//RECOGNIZE_FUNCTION_FROM_LIB
};
//============================================================================================
#endif//!definedRECOGNIZER_H