L_DocRecognize

#include "ltdoc.h"

L_INT EXT_FUNCTION L_DocRecognize(hDoc, pRecogOpts, pfnCallback, pUserData)

L_HDOC hDoc;

/* handle to the OCR document */

pRECOGNIZEOPTS pRecogOpts;

/* pointer to RECOGNIZEOPTS */

RECOGNIZESTATUSCALLBACK pfnCallback;

/* callback function */

L_VOID L_FAR * 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 RECOGNIZEOPTS 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_DocRecognize calls this callback function as it reports recognition status for each recognized page.

 

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

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 L_FAR *. 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.

Always set the pszFileName member of the RECOGNIZEOPTS structure to a valid file name.

To save the recognition results to memory, call L_DocSaveResultsToMemory.

To save the recognition result to a file, call L_DocSaveResultsToFile.

Required DLLs and Libraries

LTDOC

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_DocGetStatus, L_DocSaveResultsToMemory, L_DocFreeMemoryResults, L_DocSetRecognitionResultOptions, L_DocGetRecognitionResultOptions, L_DocEnumOutputFileFormats, L_DocGetTextFormatInfo, L_DocSaveResultsToFile, L_DocSetSpecialChar, L_DocGetSpecialChar, L_DocGetRecognizedCharacters, L_DocSetRecognizedCharacters, L_DocFreeRecognizedCharacters, RECOGNIZESTATUSCALLBACK, L_DocGetRecognizedWords, L_DocFreeRecognizedWords

Topics:

OCR Functions: User Dictionary

 

Recognizing Document Pages

Example

L_INT EXT_CALLBACK RecognizeStatusCB(L_INT nRecogPage, L_INT nError, L_VOID L_FAR * pUserData)
{
   L_TCHAR szBuffer[100];

   memset(szBuffer, 0, 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;
}

void TestRecognizePage(L_HDOC hDoc, L_INT nPageIndex)
{
   LANGIDS * pLangIds = NULL;
   L_INT nLangCount = 0;
   RECOGNIZEOPTS RecogOpts;
   RECOGMODULE_TRADEOFF TradeOff;

   L_INT nRet = L_DocGetDefaultSpellLanguages (hDoc, &pLangIds, &nLangCount);
   if (nRet == SUCCESS)
   {
      L_DocGetRecognizeModuleTradeOff(hDoc, &TradeOff);
      if (TradeOff != RECGMD_ACCURATE)
         L_DocSetRecognizeModuleTradeOff(hDoc, RECGMD_ACCURATE);

      RecogOpts.uStructSize = sizeof(RECOGNIZEOPTS);
      RecogOpts.nPageIndexStart = nPageIndex;
      RecogOpts.nPagesCount = 1;
      RecogOpts.bEnableSubSystem = TRUE;
      RecogOpts.bEnableCorrection = TRUE;
      RecogOpts.SpellLangId = pLangIds[0];
      RecogOpts.pszFileName = TEXT("c:\\testrdf.rdf");

      L_DocRecognize(hDoc, &RecogOpts, RecognizeStatusCB, NULL);
      L_DocFreeLanguages (hDoc, &pLangIds);
   }
}