L_Doc2GetCharacterChoicesExt

#include "ltdoc2.h"

L_LTDOC2_API L_INT L_Doc2GetCharacterChoicesExt(hDoc, nDocId, nPageIndex, nCharIndex, ppCharChoices, plChoicesCount)

Gets all recognized characters for the specified recognized page.

Parameters

L_HDOC2 hDoc

Handle to the OCR document.

L_INT nDocId

Document ID created by calling L_Doc2CreateDocument.

L_INT nPageIndex

A zero-based index of the recognized page containing 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 a pointer to a L_WCHAR variable to be filled with the list of available character's choices (if any are available). 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

Be sure to call L_Doc2GetRecognizedCharacters before calling L_Doc2GetCharacterChoicesExt.

L_Doc2GetCharacterChoicesExt obtains a list of recognized alternative characters and ligatures for the specified character index (if any are available). The number of alternative character's choices is in plChoicesCount.

Be sure to free the memory associated with ppCharChoices when it is no longer needed, by calling L_Doc2FreeCharacterChoices.

Required DLLs and Libraries

See Also

Functions:

Topics:

Example

L_INT Doc2GetCharacterChoicesExampleExt(L_HDOC2 hDoc, L_INT nDocId) 
{ 
   L_INT nRet; 
   RECOGNIZEOPTS2 RecogOpts; 
   RecogOpts.uStructSize = sizeof(RECOGNIZEOPTS2); 
   RecogOpts.nPageIndexStart = 0; 
   RecogOpts.nPagesCount = 1; 
   RecogOpts.SpellLangId = DOC2_LANG_ID_ENGLISH; 
 
   nRet = L_Doc2RecognizeExt (hDoc, nDocId, &RecogOpts, NULL, NULL); 
   if (nRet == SUCCESS) 
   { 
      pRECOGCHARS2 pRecogChars = NULL; 
      L_INT32 lCharsCount = 0; 
      nRet = L_Doc2GetRecognizedCharactersExt(hDoc, nDocId, 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_Doc2GetCharacterChoicesExt(hDoc, nDocId, 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 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS OCR Module - OmniPage Engine C API Help