L_Doc2SetPreProcessingOptions

#include "ltdoc2.h"

L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2SetPreProcessingOptions(hDoc, pOptions)

Sets the engine's pre-processing options.

Parameters

L_HDOC2 hDoc

Handle to the OCR document. This handle is obtained by calling the L_Doc2StartUp function.

pDOC2PREPROCESSINGOPTIONS pOptions

Pointer to DOC2PREPROCESSINGOPTIONS structure that contains the pre-processing options to be set.

Returns

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

Comments

To get the current engine's pre-processing options, call the L_Doc2GetPreProcessingOptions / L_Doc2GetPreProcessingOptionsExt function.

✅ IMPORTANT

You should call this function before calling L_Doc2FindZones / L_Doc2FindZonesExt or L_Doc2Recognize / L_Doc2RecognizeExt functions because these options affects the auto-zoning and recognition results.

Required DLLs and Libraries

See Also

Functions

Topics

Example

For an example, refer to L_Doc2SetPreProcessingOptions.

L_INT Doc2SetPreProcessingOptionsExample(L_HDOC2 hDoc, L_INT nPageIndex) 
{ 
   L_INT nRet = FAILURE; 
   DOC2PREPROCESSINGOPTIONS options; 
   RECOGNIZEOPTS2 RecogOpts; 
 
   ZeroMemory(&options, sizeof(DOC2PREPROCESSINGOPTIONS)); 
 
   nRet = L_Doc2GetPreProcessingOptions(hDoc, &options, sizeof(DOC2PREPROCESSINGOPTIONS)); 
   if(nRet == SUCCESS) 
   { 
      options.BinarizationMode = DOC2_CONVERSION_SET; 
      options.nThreshold = 218; 
 
      nRet = L_Doc2SetPreProcessingOptions(hDoc, &options); 
      if(nRet == SUCCESS) 
      { 
         L_Doc2FindZones(hDoc, nPageIndex); 
 
         RecogOpts.uStructSize = sizeof(RECOGNIZEOPTS2); 
         RecogOpts.nPageIndexStart = nPageIndex; 
         RecogOpts.nPagesCount = 1; 
         RecogOpts.SpellLangId = DOC2_LANG_ID_ENGLISH; 
 
         nRet = L_Doc2Recognize (hDoc, &RecogOpts, NULL, NULL); 
         if (nRet == SUCCESS) 
         { 
            RESULTOPTIONS2 ResOpts; 
 
            ZeroMemory(&ResOpts, sizeof(RESULTOPTIONS2)); 
            nRet = L_Doc2GetRecognitionResultOptions(hDoc, &ResOpts, sizeof(RESULTOPTIONS2)); 
            if(nRet != SUCCESS) 
               return nRet; 
 
            ResOpts.Format = DOC2_WORD_2000; 
            ResOpts.FormatLevel = DOC2_FORMAT_LEVEL_AUTO; 
            ResOpts.DocFormat = DOCUMENTFORMAT_USER; 
 
            nRet = L_Doc2SetRecognitionResultOptions(hDoc, &ResOpts); 
            if(nRet != SUCCESS) 
               return nRet; 
 
            nRet = L_Doc2SaveResultsToFile(hDoc, MAKE_IMAGE_PATH(TEXT("test.doc"))); 
            if (nRet == SUCCESS) 
               MessageBox(NULL, TEXT("The recognition results were saved to a file."), TEXT("Notice!"), MB_OK); 
         } 
      } 
   } 
 
   return nRet; 
} 

Help Version 21.0.2021.4.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS OCR Module - OmniPage Engine C API Help