L_Doc2Recognize

#include "ltdoc2.h"

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

Recognizes the specified page(s).

Parameters

L_HDOC2 hDoc

Handle to the OCR document.

pRECOGNIZEOPTS2 pRecogOpts

Pointer to a RECOGNIZEOPTS2 structure that contains recognition options.

RECOGNIZESTATUSCALLBACK2 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 / L_Doc2RecognizeExt call this callback function as it reports recognition status for each recognized page. The callback function must adhere to the following function prototype: RECOGNIZESTATUSCALLBACK2.

L_VOID * 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

Value Meaning
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 / L_Doc2SaveResultsToFileExt 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

See Also

Functions

Topics

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 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