L_Doc2GetCharacterChoices

#include "ltdoc2.h"

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

Gets all recognized characters for the specified recognized page.

Parameters

L_HDOC2 hDoc

Handle to the OCR document.

L_INT nPageIndex

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

L_INT nCharIndex

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

L_WCHAR ** 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.

L_INT32 * plChoicesCount

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

Returns

Value Meaning
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.

✅ IMPORTANT

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

See Also

Functions:

Topics:

Example

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; 
} 
Help Version 21.0.2021.4.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS OCR Module - OmniPage Engine C API Help