Export (0) Print
Expand All

Ink Recognition

Ink Recognition

Not all applications require the use of recognition. Because most applications were designed with text as their primary data type, the ability to convert ink into text is very valuable. You can use the recognition features of the Tablet PC platform application programming interface (API) query for information about the recognition engines that are available, such as what languages they recognize. You can then send a Strokes collection from an Ink object to a recognition engine and have it return a RecognitionResult object.

RecognizerContext Object

A RecognizerContext object is the instantiation of a given recognizer. The RecognizerContext object enables you to recognize a given collection of strokes synchronously or asynchronously. When recognizing asynchronously, the RecognizerContext object returns the RecognitionResult object in an event callback to the application.

Recognizers and Recognizer Objects

A single Tablet PC may have one or more recognizers available. You can query this collection of recognizers to determine which recognizer to use. A recognizer provides specific information about its capabilities such as the language it can recognize.

To determine if at least one recognizer is installed, instantiate a InkRecognizerContext object as shown in the following Microsoft® Visual C++®code example. If a recognizer is not present, this call to CoCreateInstance fails.

hr = CoCreateInstance(CLSID_InkRecognizerContext,
  NULL, CLSCTX_INPROC_SERVER,
  IID_IInkRecognizerContext,
  (void **) &g_pIInkRecoContext);
if (FAILED(hr))
  {
    ::MessageBox(NULL, TEXT("No recognizers installed.\nExiting."),
    gc_szAppName, MB_ICONERROR);
    return -1;
  }

RecognitionResult and RecognitionAlternate Objects

The results of the recognition are returned in a RecognitionResult object. The results contain a best result string in the TopString property, as well as a collection of alternative results in a RecognitionAlternates collection. The RecognitionResult object can be persisted to the original Strokes collection from which it was generated.

Show:
© 2014 Microsoft