L_Doc2GetRecognizedWords

#include "ltdoc2.h"

L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2GetRecognizedWords(hDoc, nPageIndex, ppRecogWords, uStructSize, pnWordsCount)

Gets all recognized words for the specified recognized page.

Parameters

L_HDOC2 hDoc

Handle to the OCR document.

L_INT nPageIndex

Index of the recognized page from which to get the recognized words. This index is zero-based.

pRECOGWORDS2 * ppRecogWords

Address of a pointer to a RECOGWORDS2 structure into which an array of RECOGWORDS2 structures will be allocated and updated.

L_UINT uStructSize

Size in bytes, of the structure pointed to by ppRecogWords. Should be set to sizeof(RECOGWORDS2).

L_INT * pnWordsCount

Pointer to a variable to be updated with the number of elements in the ppRecogWords array.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

This function updates ppRecogWords with an array containing all of the recognized words for the specified recognized page. Memory for the array of structures pointed to by ppRecogWords is allocated by this function.

This function also updates the variable pointed to by pnWordsCount with the number of recognized words.

Once the ppRecogWords parameter is no longer needed, free the memory associated with it by calling the L_Doc2FreeRecognizedWords / L_Doc2FreeRecognizedWords function.

This function should only be called after successfully starting a recognition process by calling the L_Doc2Recognize / L_Doc2RecognizeExt function.

This function just combines the recognized characters for the specified page into words. To change the contents of the recognized words, change the set of recognized characters by calling the L_Doc2SetRecognizedCharacters / L_Doc2SetRecognizedCharactersExt function. To save the updated recognized characters to a file, call the L_Doc2SaveResultsToFile / L_Doc2SaveResultsToFileExt function.

Required DLLs and Libraries

See Also

Functions

Topics

Example

L_INT Doc2GetRecognizedWordsExample(L_HDOC2 hDoc) 
{ 
   L_INT nRet; 
   pRECOGWORDS2 pRecogWords = NULL; 
   L_INT nWordsCount = 0; 
 
   nRet = L_Doc2GetRecognizedWords(hDoc, 0, &pRecogWords, sizeof(RECOGWORDS2), &nWordsCount); 
   if (nRet == SUCCESS) 
   { 
      L_TCHAR szBuffer[1500]; 
      wsprintf(szBuffer, TEXT("Total Recognized words = %d"), nWordsCount); 
      MessageBox(NULL, szBuffer, TEXT("Notice!"), MB_OK); 
 
      for (L_INT i=0; i<nWordsCount; i++) 
      { 
         wsprintf(szBuffer, TEXT("Word = %s\nZone Index = %d\nArea {%d, %d, %d, %d}"), 
                         pRecogWords[i].szWord, 
                         pRecogWords[i].nZoneIndex, 
                         pRecogWords[i].rcWordArea.left, 
                         pRecogWords[i].rcWordArea.top, 
                         pRecogWords[i].rcWordArea.right, 
                         pRecogWords[i].rcWordArea.bottom); 
         MessageBox(NULL, szBuffer, TEXT("Notice!"), MB_OK); 
      } 
 
      nRet = L_Doc2FreeRecognizedWords(hDoc, &pRecogWords); 
      if(nRet != SUCCESS) 
         return nRet; 
   } 
   else 
      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