Unboxed Recognition

For recognition of unboxed handwriting pics/PENAPI00090001.gif that is, writing without visual guides as specified by a GUIDE structure, an application must call the GetResultsHRC function. This function fills an array of HRCRESULT objects, each containing a separate guess by the recognizer. The number of HRCRESULT objects in the array is always less than or equal to the maximum number of guesses requested through the SetMaxResultsHRC function.

An example will clarify this. Assume an application contains the following instructions:

#define MAX_GUESS 5 // Maximum number of guesses allowed

.

.

.

SetMaxResultsHRC( hrc1, MAX_GUESS );

The user next writes a word that the recognizer associated with hrc1 guesses to be, in descending order of probability, either "clear," "dear," "clean," "dean," or "deer." Though it might have generated even more guesses, the recognizer is constrained to stop after its fifth guess by the earlier call to SetMaxResultsHRC. In this case, a subsequent call to GetResultsHRC fills an array of up to five HRCRESULT objects, the first HRCRESULT containing the word "clear," the second the word "dear," and so forth.

An HRCRESULT object does not contain a normal ASCII string representation of a guess. This is not possible since a guess might be made up of a gesture, shape, or other entity that has no ASCII equivalent. Instead, an HRCRESULT contains a string of symbol values, which are 32-bit numbers type-defined as SYV.

Symbol values can represent geometric shapes, gestures, letters of the alphabet, Japanese Kanji characters, musical notes, electronic symbols, or any other symbols defined by the recognizer. The Pen API provides the function SymbolToCharacter to convert the null-terminated symbol string in HRCRESULT to an ASCII string.

The following code continues the example above, illustrating how to retrieve and display the five guesses returned by the recognizer:

#define MAX_GUESS 5 // Maximum number of guesses allowed

#define MAX_CHAR 50 // Maximum number of characters in

// a single guess

HRCRESULT result[MAX_GUESS]; // Array for recognition result objects

int cGuess;

.

.

.

SetMaxResultsHRC( hrc1, MAX_GUESS );

.

.

.

//

// Get all (non-gesture) guesses available, and if no errors,

// convert to ASCII strings and display them. Note in our

// example the following call returns the value 5 to cGuess.

//

cGuess = GetResultsHRC( hrc1, GRH_NONGESTURE,

(LPHRCRESULT) &result, MAX_GUESS );

if (cGuess > 0)

{

int i, cSyv, cChar;

char szText[MAX_CHAR]; // Buffer for converted text

SYV rgSyv[MAX_CHAR]; // Buffer for symbol string

//

// Loop cGuess (5) times, retrieving each time a symbol string

// representing a different guess. Convert the symbol string

// to a normal ASCII string and display it.

//

// In our example, the five iterations of this loop display the

// words "clear," "dear," "clean," "dean," and "deer."

//

for (i = 0; i < cGuess; i++)

{

cSyv = GetSymbolsHRCRESULT( result[i], 0, rgSyv, MAX_CHAR );

if (cSyv > 0)

{

SymbolToCharacter( (LPSYV) rgSyv, cSyv,

(LPSTR) szText, (LPINT) &cChar );

.

. // After converting to ASCII

. // string, display text

TextOut( hdc, nX, nY, (LPSTR) szText, cChar );

.

.

.

}

DestroyHRCRESULT( result[i] ); // When finished with results,

result[i] = NULL; // destroy HRCRESULT objects

}

}

For another example of how to use the GetResultsHRC function, see "Step 9: PE_RESULT Message" in Chapter 2. If an application must retrieve an unknown number of symbol values from the recognizer, it should follow these three steps:

  1. Call GetSymbolCountHRCRESULT to determine the number of symbol values the recognizer can return.

  2. Allocate a sufficient buffer for the values.

  3. Call GetSymbolsHRCRESULT. to copy the symbol values to the buffer.

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database