📄 hwr.c
字号:
/******************************************************************************
(c) copyright Motorola Semiconductors Hong Kong Limited 1994, 1995, 1996, 1997, 1998
ALL RIGHTS RESERVED
******************************************************************************
Project Name : Personal Portable System Manager, PPSM
Project No. : PDAPSM031
Title : Handwriting Recognition API
File Name : hwr.c
Created On : 08/09/95
**********************************************************************/
#include <stdlib.h>
#include <string.h>
#include <setjmp.h>
#include <ppsm.h>
#include "..\..\const.h"
#include <hw.h>
extern U16 HandWriteRecognizeType;
extern U16 HandWriteRecognizeNum;
extern U32 MainMenuTask;
PPSM_MESSAGE msg;
U32 tempA6;
#define MAXPOINTS 2048
int nLength=0;
BYTE pTrace[MAXPOINTS+8];
char szResult[100];
BYTE* pbPot=0xd0000;
BYTE ram[16*1024];
/*
* ResetRecEngine()
*
* Resets / reinitializes handwriting recognition engine when
* system is reset.
*
*/
void ResetRecEngine(void)
{
/* insert code here to reset the engine */
msg.messageType=MESSAGE_IRPT;
msg.message=IRPT_USER;
msg.misc=0x2345;
msg.data=0;
msg.size=0;
msg.reserved=FALSE;
nLength = 0;
}
/*
* InitRecEngine(void)
*
* Initialize handwriting recognition engine.
* This is called once at power up.
*/
void InitRecEngine(void)
{
/* insert code to initialize the engine at power up */
nLength = 0;
// HWSetDictionary( 0x280000+0x98e68 );
HWSetDictionary( (DWORD)ram,CONST_BEGIN+0x9f1b4 );
}
/*
* ProcessStroke(U16 numPoints, P_POINT strokeData, U32 inputAreaId)
*
* Process one stroke of data received from the system.
* This is called whenever there is a stroke of data received.
*
*/
void ProcessStroke(U16 numPoints, P_POINT strokeData, U32 inputAreaId )
{
/* insert code to handle one stroke of ink data */
int i;
if( !numPoints )
return;
if( nLength + numPoints*2 > MAXPOINTS )
return;
for( i=0; i<numPoints; i++ )
{
pTrace[nLength++] = (BYTE)strokeData[i].x;
pTrace[nLength++] = (BYTE)strokeData[i].y;
}
pTrace[nLength-1] = 0;
}
/*
* RecognizeInput(P_U16 numCandidates, P_TEXT *candidates)
*
* Recognizes the input character.
* This is called when all strokes of a character have been
* answered
*
*/
void RecognizeInput(P_U16 numCandidates, P_TEXT *candidates)
{
/* insert code to call upon the handwriting recognition
engine to recognise the strokes entered thus
far. */
//char szResult[21];
WORD sum = 0;
jmp_buf gotoBuf;
int i,offset=0;
U32 delay;
if( !nLength )
{
*numCandidates = 0;
return;
}
pTrace[nLength++] = 0xff;
pTrace[nLength++] = 0xff;
//realize recognition
/* if(setjmp(gotoBuf)==0)
{
sum = HWRecognize( pTrace, nLength, szResult, 5, ALC_CHINESE_COMMON );
szResult[sum*2]=0;
longjmp(gotoBuf,1);
}
*candidates = &szResult;
*numCandidates = strlen(szResult);
*/
//// sum = HWRecognize( pTrace, nLength, szResult, HandWriteRecognizeNum, HandWriteRecognizeType );
*candidates = (P_TEXT)szResult;
*numCandidates = sum;
AdvSendMessage(MainMenuTask,&msg,SWAP_TASK_BACK_LATER);
/*
for(delay=0x7ffff;delay>0;delay--);
strcpy(szResult,"胡晨");
*numCandidates = 2;
*candidates = (P_TEXT)szResult;
*/
//to test speed of recognition
/*
for( i=0; i<20; i++ )
{
sum = *(WORD*)(pbPot+offset);
sum = (sum << 8) | (sum >> 8);
HWRecognize( pbPot+offset+6, sum-6, szResult, 5, ALC_CHINESE_COMMON);
offset += sum;
}
*/
//*numCandidates =0;
nLength = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -