L_OcrEngine_GetLanguageManager

#include "ltocr.h"

L_LTOCR_API L_INT EXT_FUNCTION L_OcrEngine_GetLanguageManager(engine, languageManager)

Returns a handle to the OCR engine language manager.

Parameters

L_OcrEngine engine

Handle to the OCR engine.

L_OcrLanguageManager* languageManager

Pointer to a L_OcrLanguageManager handle to be updated.

Returns

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

Comments

This function returns a handle to the OCR engine language manager where you get access to the language environment of the character sets used by this OCR engine.

The L_OcrLanguageManager allows you to do the following:

Required DLLs and Libraries

See Also

Functions

Topics

Example

L_INT L_OcrEngine_GetLanguageManagerExample() 
{ 
   L_OcrEngine ocrEngine = NULL; 
   L_OcrLanguageManager languageManager = NULL; 
   L_OcrLanguage* supportedLanguages = NULL; 
   L_OcrLanguage* additionalLanguages = NULL; 
   L_OcrLanguage* enabledLanguages = NULL; 
   L_UINT languageCount = 0; 
 
   // Create an instance of the engine 
   L_OcrEngineManager_CreateEngine(L_OcrEngineType_Advantage, &ocrEngine); 
 
   // Start the engine using default parameters 
   L_OcrEngine_Startup(ocrEngine, NULL, OCR_ADVANTAGE_RUNTIME_DIR); 
 
   // Get the OCR Language Manager 
   L_OcrEngine_GetLanguageManager(ocrEngine, &languageManager); 
 
   // Show languages supported by this engine 
   L_OcrLanguageManager_GetSupportedLanguages(languageManager, &supportedLanguages, &languageCount); 
 
   std::cout << "Supported languages (" << languageCount << "):\n"; 
   for(L_UINT index = 0; index < languageCount; index++) 
   { 
      // Print the language name of this language 
      L_TCHAR szLanguageName[20]; 
      L_OcrLanguageManager_GetLanguageName(supportedLanguages[index], szLanguageName, _countof(szLanguageName)); 
      std::cout << szLanguageName << std::endl; 
   } 
   // free supportedLanguages 
   L_OcrMemory_Free(supportedLanguages); 
 
 
   // Show engine additional supported languages that you might want to download and use 
   L_UINT additionalLanguagesCount = 0; 
   L_OcrLanguageManager_GetAdditionalLanguages(languageManager, &additionalLanguages, &additionalLanguagesCount); 
 
   std::cout << "Additional languages (" << additionalLanguagesCount << "):\n"; 
   for(L_UINT index = 0; index < additionalLanguagesCount; index++) 
   { 
      // Print the language name of this language 
      L_TCHAR szLanguageName[20]; 
      L_OcrLanguageManager_GetLanguageName(additionalLanguages[index], szLanguageName, _countof(szLanguageName)); 
      std::cout << szLanguageName << std::endl; 
   } 
 
   // free additionalLanguages 
   L_OcrMemory_Free(additionalLanguages); 
 
 
   // Show enabled languages by this engine 
   L_OcrLanguageManager_GetEnabledLanguages(languageManager, &enabledLanguages, &languageCount); 
 
   std::cout << std::endl; 
   std::cout << "Enabled languages (" << languageCount << "):\n"; 
   for(L_UINT index = 0; index < languageCount; index++) 
   { 
      // Print the language name of this language 
      L_TCHAR szLanguageName[20]; 
      L_OcrLanguageManager_GetLanguageName(supportedLanguages[index], szLanguageName, _countof(szLanguageName)); 
      std::cout << szLanguageName << std::endl; 
 
      // If you have the language name and wish to get its values you can call the below function: 
      L_OcrLanguage languageValue = L_OcrLanguage_None; 
      L_OcrLanguageManager_GetLanguageValue(szLanguageName, &languageValue); 
   } 
 
   // Try to enable the English language 
   L_INT ret = L_OcrLanguageManager_IsLanguageSupported(languageManager, L_OcrLanguage_EN); 
   if(ret == SUCCESS) 
   { 
      L_OcrLanguage languagesToEnable[1] = { L_OcrLanguage_EN }; 
      L_OcrLanguageManager_EnableLanguages(languageManager, languagesToEnable, 1); 
   } 
 
   // Do the rest of your stuff here, Load image, recognize and save 
 
   // free enabledLanguages 
   L_OcrMemory_Free(enabledLanguages); 
 
   //CLEANUP 
   L_OcrEngine_Destroy(ocrEngine); 
 
   return SUCCESS; 
} 
Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS OCR Module - LEAD Engine C API Help