L_Doc2Recognize

#include "ltdoc2.h"

L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2Recognize(hDoc, pRecogOpts, pfnCallback, pUserData)

L_HDOC2 hDoc;

handle to the OCR document

pRECOGNIZEOPTS2 pRecogOpts;

pointer to RECOGNIZEOPTS2

RECOGNIZESTATUSCALLBACK2 pfnCallback;

callback function

L_VOID * pUserData;

pointer to more parameters for the callback

Recognizes the specified page(s).

Parameter

Description

hDoc

Handle to the OCR document.

pRecogOpts

Pointer to a RECOGNIZEOPTS2 structure that contains recognition options.

pfnCallback

Optional callback function for reporting recognition status.

 

If you do not provide a callback function, use NULL as the value of this parameter. Use NULL if no progress reporting is needed.

 

If you do provide a callback function, use the function pointer as the value of this parameter.

 

L_Doc2Recognize calls this callback function as it reports recognition status for each recognized page.

 

The callback function must adhere to the following function prototype: RECOGNIZESTATUSCALLBACK2.

pUserData

Void pointer that you can use to pass one or more additional parameters that the callback function needs.

 

To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer to the appropriate data type to access your variable or structure.

 

If the additional parameters are not needed, you can pass NULL in this parameter.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function will recognize the specified page or pages from the OCR document.

To save the recognition result to a file, call the L_Doc2SaveResultsToFile function.

Note

Zones recognition for module DOC2_RECOGMODULE_OMNIFONT_PLUS2W is faster but less accurate.
In comparison however, a module of type DOC2_RECOGMODULE_OMNIFONT_PLUS3W will be more accurate but slower.

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_Doc2GetStatus, L_Doc2SetRecognitionResultOptions, L_Doc2GetRecognitionResultOptions, L_Doc2EnumOutputFileFormats, L_Doc2GetTextFormatInfo, L_Doc2SaveResultsToFile, L_Doc2SetSpecialChar, L_Doc2GetSpecialChar, L_Doc2GetRecognizedCharacters, L_Doc2SetRecognizedCharacters, L_Doc2FreeRecognizedCharacters, RECOGNIZESTATUSCALLBACK2, L_Doc2GetRecognizedWords, L_Doc2FreeRecognizedWords, L_Doc2GetRecognizedCharactersColors, L_Doc2GetOutputFormatSettings, L_Doc2SetOutputFormatSettings

Topics:

OCR Functions: User Dictionary

 

Recognizing Document Pages

Example

L_INT EXT_CALLBACK RecognizeStatusCB(L_INT nRecogPage, 
L_INT nError, 
L_VOID* pUserData) 
{ 
   UNREFERENCED_PARAMETER(pUserData); 
   L_TCHAR szBuffer[100]; 
   ZeroMemory(szBuffer, sizeof(szBuffer)); 
   wsprintf(szBuffer, TEXT("Recognized page index = %d\nRecognition Return value = %d\n"), nRecogPage, nError); 
   MessageBox(NULL, szBuffer, TEXT("Notice!"), MB_OK); 
   return SUCCESS; 
} 
L_INT Doc2RecognizeExample(L_HDOC2 hDoc,L_INT nPageIndex) 
{ 
   L_INT nRet; 
   DOC2_LANGIDS* pLangIds = NULL; 
   L_INT nLangCount = 0; 
   RECOGNIZEOPTS2 RecogOpts; 
   DOC2_RECOGMODULE_TRADEOFF TradeOff; 
   nRet = L_Doc2GetDefaultSpellLanguages (hDoc, &pLangIds, &nLangCount); 
   if (nRet == SUCCESS) 
   { 
      nRet = L_Doc2GetRecognizeModuleTradeOff(hDoc, &TradeOff); 
      if(nRet != SUCCESS) 
         return nRet; 
      if (TradeOff != DOC2_RECGMD_ACCURATE) 
      { 
         nRet = L_Doc2SetRecognizeModuleTradeOff(hDoc, DOC2_RECGMD_ACCURATE); 
         if(nRet != SUCCESS) 
            return nRet; 
      } 
      RecogOpts.uStructSize = sizeof(RECOGNIZEOPTS2); 
      RecogOpts.nPageIndexStart = nPageIndex; 
      RecogOpts.nPagesCount = 1; 
      RecogOpts.bEnableSubSystem = TRUE; 
      RecogOpts.bEnableCorrection = TRUE; 
      RecogOpts.SpellLangId = pLangIds[0]; 
      nRet = L_Doc2Recognize(hDoc, &RecogOpts, RecognizeStatusCB, NULL); 
      if(nRet != SUCCESS) 
         return nRet; 
      nRet = L_Doc2FreeLanguages (hDoc, &pLangIds); 
      if(nRet != SUCCESS) 
         return nRet; 
   } 
   else 
      return nRet; 
   return SUCCESS; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Professional OCR C API Help