インク認識エンジンを作成するために実装する必要があるメソッドは、インク対応アプリケーションによって直接ではなく、Tablet PC プラットフォーム API によって呼び出されます。
次の手順は、これらのメソッドを実装するための一般的な呼び出しシーケンスを表します。
- DLL が読み込まれます。
- HRECOGNIZER ハンドルが作成されます。
- HRECOCONTEXT ハンドルが作成されます。
- 認識エンジンのオプションとモードは、このコンテキストに対して設定されます。
- ストロークがインク データに追加されます。
- 入力は終了します。
- インクが認識されます。
- 認識結果が返されます。
- HRECOCONTEXT ハンドルが破棄されます。
- HRECOGNIZER ハンドルが破棄されます。
呼び出しシーケンスは、次のコード アウトラインにも示されています。
CreateRecognizer(CLSID, &hrec);
while (more pieces of ink to recognize ... )
{
// Create a context, once per piece of ink to be recognized
hrc = CreateContext(hrec, &hrc);
// Functions to set up options and modes for this context
SetGuide(hrc, pGuide, 0);
SetFactoid(hrc, 5, PHONE); // only if in application with forms
SetFlags(hrc, RECOFLAG_WORDMODE); // rare, only if wanting word mode, no out-of-dictionary, or single segmentation
SetWordList(hrc, hwl);
// Adding all the strokes in this piece of ink
while (more strokes ... )
{
AddStroke(hrc, NULL, 800, pPacket, pXForm); // one call per stroke
}
EndInkInput(hrc);
// This gets the ink recognized
Process(hrc);
// If this is a simple application, it calls this for a simple answer
GetBestResultString(hrc, length, buffer);
// If this is a complex application, it calls this for a complete answer
GetLatticePtr(hrc, &pLattice);
// Destroy the context
DestroyContext(hrc);
}
// Called just before the application shuts down
DestroyRecognizer(hrec);
関連トピック