L_OcrSettingManager_LoadFile

Summary

Loads the OCR engine settings from a disk file.

Syntax

#include "ltocr.h"

L_LTOCR_API L_INT EXT_FUNCTION L_OcrSettingManager_LoadFile(settingManager, fileName)

Parameters

L_OcrSettingManager settingManager

Handle to the OCR engine setting manager.

const L_TCHAR* fileName

The name of the file containing the settings.

Returns

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

See Also

Functions

Topics

Example

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_LEAD, &ocrEngine); 
   if(retCode != SUCCESS) 
      return retCode; 
    
   // Start the engine using default parameters 
   L_OcrEngine_Startup(ocrEngine, NULL, OCR_LEAD_RUNTIME_DIR); 
 
   L_OcrEngine_GetSettingManager(ocrEngine, &ocrSettingManager); 
 
   //************************************** 
   //LEAD engine 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("LEADengineSettings.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_LEAD, &ocrEngine); 
   if(retCode != SUCCESS) 
      return retCode; 
 
   // Start the engine using default parameters 
   L_OcrEngine_Startup(ocrEngine, NULL, OCR_LEAD_RUNTIME_DIR); 
 
   // Get the setting manager again 
   L_OcrEngine_GetSettingManager(ocrEngine, &ocrSettingManager); 
 
   // Load the settings 
   L_OcrSettingManager_LoadFile(ocrSettingManager, MAKE_IMAGE_PATH(L_TEXT("LEADengineSettings.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 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS OCR Module - LEAD Engine C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.