#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.
Handle to the OCR document.
Index of the recognized page from which to get the recognized words. This index is zero-based.
Address of a pointer to a RECOGWORDS2 structure into which an array of RECOGWORDS2 structures will be allocated and updated.
Size in bytes, of the structure pointed to by ppRecogWords. Should be set to sizeof(RECOGWORDS2).
Pointer to a variable to be updated with the number of elements in the ppRecogWords array.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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
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;
}