#include "ltdoc2.h"
L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2SetPreProcessingOptions(hDoc, pOptions)
L_HDOC2 hDoc; |
handle to the OCR document |
pDOC2PREPROCESSINGOPTIONS pOptions; |
pre-processing options |
Sets the engine's pre-processing options.
Parameter |
Description |
hDoc |
Handle to the OCR document. This handle is obtained by calling the L_Doc2StartUp function. |
pOptions |
Pointer to DOC2PREPROCESSINGOPTIONS structure that contains the pre-processing options to be set. |
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
To get the current engine's pre-processing options, call the L_Doc2GetPreProcessingOptions function.
Note: You should call this function before calling L_Doc2FindZones or L_Doc2Recognize functions because these options affects the auto-zoning and recognition results.
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. |
Functions: |
|
Topics: |
For an example, refer to L_Doc2SetPreProcessingOptions.
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
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;
}