L_Doc2GetCharacterChoices

#include "ltdoc2.h"

L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2GetCharacterChoices(hDoc, nPageIndex, nCharIndex, ppCharChoices, plChoicesCount)

L_HDOC2 hDoc;

/* handle to the OCR document */

L_INT nPageIndex;

/* page index */

L_INT nCharIndex;

/* character index */

L_WCHAR ** ppCharChoices;

/* pointer to string variable */

L_INT32 * plChoicesCount;

/* pointer to the number of character's choices */

Gets all recognized characters for the specified recognized page.

Parameter

Description

hDoc

Handle to the OCR document.

nPageIndex

A zero-based index of the recognized page where the character you wish to get its choices are located

nCharIndex

A zero-based index of the character to get its choices.

ppCharChoices

Address of pointer to a L_WCHAR variable to be filled with the list of available character's choices (if any are available). You can define a variable of type L_WCHAR* and pass its address.

plChoicesCount

Pointer to a variable to be updated with the number of choices available for the specified character index.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function obtains a list of recognized alternative characters and ligatures for the specified character index (if any are available).

This function obtains the number of alternative character's choices in plChoicesCount.

You must free the memory associated with ppCharChoices parameter when it is no longer needed, by calling the L_Doc2FreeCharacterChoices function.

This function should not be called before calling the L_Doc2GetRecognizedCharacters function.

Required DLLs and Libraries

LTDOC2

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

L_Doc2FreeCharacterChoices, L_Doc2GetWordSuggestions, L_Doc2FreeWordSuggestions, L_Doc2GetRecognizedCharacters, L_Doc2GetRecognizedWords

Topics:

OCR Functions: Recognition

 

Recognizing Document Pages

Example

L_LTDOC2TEX_API L_INT Doc2GetCharacterChoicesExample(L_HDOC2 hDoc)
{
   L_INT nRet;
   RECOGNIZEOPTS2 RecogOpts;
   RecogOpts.uStructSize = sizeof(RECOGNIZEOPTS2);
   RecogOpts.nPageIndexStart = 0;
   RecogOpts.nPagesCount = 1;
   RecogOpts.SpellLangId = DOC2_LANG_ID_ENGLISH;

   nRet = L_Doc2Recognize (hDoc, &RecogOpts, NULL, NULL);
   if (nRet == SUCCESS)
   {
      pRECOGCHARS2 pRecogChars = NULL;
      L_INT32 lCharsCount = 0;
      nRet = L_Doc2GetRecognizedCharacters(hDoc, 0, &pRecogChars, &lCharsCount, sizeof(RECOGCHARS2));
      if (nRet == SUCCESS)
      {
         for (L_INT32 i=0; i<lCharsCount; i++)
         {
            L_WCHAR * pCharChoices = NULL;
            L_INT nChoicesCount = 0;
            nRet = L_Doc2GetCharacterChoices(hDoc, 0, i, &pCharChoices, &nChoicesCount);
            if(nRet == SUCCESS && nChoicesCount > 0)
            {
               L_TCHAR szBuffer[1024];
               ZeroMemory(szBuffer, sizeof(szBuffer));

               wsprintf(szBuffer, TEXT("Character Index: %d\nCharacter Code: %s\nChoices Count: %d"), i, pRecogChars[i].wGuessCode, nChoicesCount);
               MessageBox(NULL, szBuffer, TEXT("Character Choices Count"), MB_OK);

               L_Doc2FreeCharacterChoices(hDoc, &pCharChoices);
            }
         }

         nRet = L_Doc2FreeRecognizedCharacters(hDoc, &pRecogChars);
         if(nRet != SUCCESS)
            return nRet;
      }
   }
   return SUCCESS;
}