L_OcrSettingManager_LoadFile

#include "ltocr.h"

L_LTOCR_API L_INT EXT_FUNCTION L_OcrSettingManager_LoadFile(settingManager, fileName)

L_OcrSettingManager settingManager; handle to the OCR engine setting manager
const L_TCHAR* fileName; The name of the file containing the settings

Loads the OCR engine settings from a disk file.

Parameter Description
settingManager Handle to the OCR engine setting manager.
fileName The name of the file containing the settings.

Returns

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

Comments

Loads the OCR engine settings from a disk file.

Once you set up the OCR engine, you can re-use these settings by saving the engine state into XML file on disk. You can later reload these settings and use them in the same or different instance of L_OcrEngine.

Required DLLs and Libraries

LTOCR
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_OcrSettingManager_GetSettingCount, L_OcrSettingManager_GetSettingName, L_OcrSettingManager_GetSettingDescriptors, L_OcrSettingManager_IsSettingNameSupported, L_OcrSettingManager_GetSettingValueType, L_OcrSettingManager_GetSettingDescriptor, L_OcrSettingManager_GetIntegerValue, L_OcrSettingManager_SetIntegerValue, L_OcrSettingManager_GetEnumValue, L_OcrSettingManager_SetEnumValue, L_OcrSettingManager_GetEnumValueAsString, L_OcrSettingManager_SetEnumValueAsString, L_OcrSettingManager_GetDoubleValue, L_OcrSettingManager_SetDoubleValue, L_OcrSettingManager_GetBooleanValue, L_OcrSettingManager_SetBooleanValue, L_OcrSettingManager_GetStringValue, L_OcrSettingManager_SetStringValue, L_OcrSettingManager_GetValue, L_OcrSettingManager_SetValue, L_OcrSettingManager_SaveFile
Topics: Programming with LEADTOOLS OCR Advantage
Starting and Shutting Down the OCR Engine
LEADTOOLS OCR Advantage Engine Settings

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
#define OCR_ADVANTAGE_RUNTIME_DIR TEXT("C:\\LEADTOOLS 19\\Bin\\Common\\OcrAdvantageRuntime") 
L_INT L_OcrSettingManager_LoadFileExample() 
{ 
   L_OcrEngine ocrEngine = NULL; 
   L_OcrSettingManager ocrSettingManager = NULL; 
   // Create an instance of the engine 
   L_INT retCode = L_OcrEngineManager_CreateEngine(L_OcrEngineType_Advantage, &ocrEngine); 
   if(retCode != SUCCESS) 
      return retCode; 
   // Start the engine using default parameters 
   L_OcrEngine_Startup(ocrEngine, NULL, OCR_ADVANTAGE_RUNTIME_DIR); 
   L_OcrEngine_GetSettingManager(ocrEngine, &ocrSettingManager); 
   //************************************** 
   //Advantage settings 
   //************************************** 
   // Enum 
   L_OcrSettingManager_SetEnumValue(ocrSettingManager, L_TEXT("Recognition.Zoning.Options"), 0); 
   L_OcrSettingManager_SetEnumValue(ocrSettingManager, L_TEXT("Recognition.Fonts.DetectFontStyles"), 0); 
   // Boolean 
   L_OcrSettingManager_SetBooleanValue(ocrSettingManager, L_TEXT("Recognition.Fonts.RecognizeFontAttributes"), L_TRUE); 
   L_OcrSettingManager_SetBooleanValue(ocrSettingManager, L_TEXT("Recognition.Zoning.DisableMultiThreading"), L_FALSE); 
   // Integer 
   L_OcrSettingManager_SetIntegerValue(ocrSettingManager, L_TEXT("Recognition.Threading.MaximumThreads"), 4); 
   L_OcrSettingManager_SetIntegerValue(ocrSettingManager, L_TEXT("Recognition.Preprocess.MinimumAutoRotateConfidence"), 30); 
   // String 
   L_OcrSettingManager_SetStringValue(ocrSettingManager, L_TEXT("Recognition.CharacterFilter.MinimumPixelSizeExcludeCharacters"), L_TEXT("")); 
   // Save the settings 
   L_OcrSettingManager_SaveFile(ocrSettingManager, MAKE_IMAGE_PATH(L_TEXT("AdvantageSettings.xml")), NULL); 
   //************************************** 
   // End settings 
   //************************************** 
   L_OcrEngine_Destroy(ocrEngine); 
   ocrEngine = NULL; 
   // Now create another instance of the engine, load the settings and make sure they are the same 
   L_OcrEngineManager_CreateEngine(L_OcrEngineType_Advantage, &ocrEngine); 
   if(retCode != SUCCESS) 
      return retCode; 
   // Start the engine using default parameters 
   L_OcrEngine_Startup(ocrEngine, NULL, OCR_ADVANTAGE_RUNTIME_DIR); 
   // Get the setting manager again 
   L_OcrEngine_GetSettingManager(ocrEngine, &ocrSettingManager); 
   // Load the settings 
   L_OcrSettingManager_LoadFile(ocrSettingManager, MAKE_IMAGE_PATH(L_TEXT("AdvantageSettings.xml"))); 
   //************************************** 
   //// Check the settings 
   //************************************** 
   L_UINT setUIntValue = 0; 
   L_OcrSettingManager_GetEnumValue(ocrSettingManager, L_TEXT("Recognition.Zoning.Options"), &setUIntValue); 
   if(setUIntValue != 0 /* VALUE FROM ABOVE */) 
      std::wcout << L"Unexpected value set for Recognition.Zoning.Options" << std::endl; 
   L_OcrSettingManager_GetEnumValue(ocrSettingManager, L_TEXT("Recognition.Fonts.DetectFontStyles"), &setUIntValue); 
   if(setUIntValue != 0 /* VALUE FROM ABOVE */) 
      std::wcout << L"Unexpected value set for Recognition.Fonts.DetectFontStyles" << std::endl; 
   L_BOOL setBoolValue = L_FALSE; 
   L_OcrSettingManager_GetBooleanValue(ocrSettingManager, L_TEXT("Recognition.Fonts.RecognizeFontAttributes"), &setBoolValue); 
   if(setBoolValue != L_TRUE /* VALUE FROM ABOVE */) 
      std::wcout << L"Unexpected value set for Recognition.Fonts.RecognizeFontAttributes" << std::endl; 
   L_OcrSettingManager_GetBooleanValue(ocrSettingManager, L_TEXT("Recognition.Zoning.DisableMultiThreading"), &setBoolValue); 
   if(setBoolValue != L_FALSE /* VALUE FROM ABOVE */) 
      std::wcout << L"Unexpected value set for Recognition.Zoning.DisableMultiThreading" << std::endl; 
   L_INT setIntValue = -1; 
   L_OcrSettingManager_GetIntegerValue(ocrSettingManager, L_TEXT("Recognition.Threading.MaximumThreads"), &setIntValue); 
   if(setIntValue != 4 /* VALUE FROM ABOVE */) 
      std::wcout << L"Unexpected value set for Recognition.Threading.MaximumThreads" << std::endl; 
   L_OcrSettingManager_GetIntegerValue(ocrSettingManager, L_TEXT("Recognition.Preprocess.MinimumAutoRotateConfidence"), &setIntValue); 
   if(setIntValue != 30 /* VALUE FROM ABOVE */) 
      std::wcout << L"Unexpected value set for Recognition.Preprocess.MinimumAutoRotateConfidence" << std::endl; 
   // String 
   L_TCHAR* setStringValue = NULL; 
   L_OcrSettingManager_GetStringValue(ocrSettingManager, L_TEXT("Recognition.CharacterFilter.MinimumPixelSizeExcludeCharacters"), &setStringValue); 
   if(lstrcmp(setStringValue, TEXT("")) != 0) 
      std::wcout << L"Unexpected value set for Recognition.CharacterFilter.MinimumPixelSizeExcludeCharacters" << std::endl; 
   // Free the retrieved string setting value 
   if(setStringValue != NULL) 
      L_OcrMemory_Free(setStringValue); 
   //CLEANUP 
   L_OcrEngine_Destroy(ocrEngine); 
   return SUCCESS; 
} 

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