LEADTOOLS OCR (Leadtools.Forms.Ocr assembly)
LEAD Technologies, Inc

IOcrLanguageManager Interface

Example 





Members 
Provides access to the language environment of the character sets used by the IOcrEngine. .NET support
Object Model
IOcrLanguageManager Interface
Syntax
public interface IOcrLanguageManager 
'Declaration
 
Public Interface IOcrLanguageManager 
'Usage
 
Dim instance As IOcrLanguageManager
public interface IOcrLanguageManager 
function Leadtools.Forms.Ocr.IOcrLanguageManager() 
public interface class IOcrLanguageManager 
Remarks

You can access the instance of the IOcrLanguageManager used by an IOcrEngine through the IOcrEngine.LanguageManager property.

The language environment defines the character set(s) recognized by the OCR engine. For example, if you enable the English and German languages, the German characters (ä, Ä, é, ö, Ö, ü, Ü, ß) will be combined with the English characters to define the set recognized by the engine. The language environment does not perform spell checking however, for that, refer to IOcrSpellCheckManager.

The IOcrLanguageManager allows you to do the following:

The language values used throughout the LEADTOOLS OCR toolkit is a string value based on RFC 4646 (Windows Vista and later). The name could be an ISO 639 two-letter lowercase culture code associated with a language or a combination of ISO 630 and ISO 3166 two-letter uppercase subculture code associated with a country or region.

You must call the IOcrEngine.Startup method before you can use the IOcrEngine.LanguageManager property.

Note: The IOcrLanguageManager state is also saved when the engine settings are saved. For more information, refer to IOcrSettingManager.

Example
Copy CodeCopy Code  
Public Sub OcrLanguageManagerExample()
   ' Create an instance of the engine
   Using ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Plus, False)
      ' Start the engine using default parameters
      ocrEngine.Startup(Nothing, Nothing, Nothing, Nothing)
      ' Show languages supported by this engine
      Dim supportedLanguages() As String = ocrEngine.LanguageManager.GetSupportedLanguages()

      Console.WriteLine("Supported languages:")
      For Each supportedLanguage As String In supportedLanguages
         ' Get the friendly name of this language using the .NET CultureInfo class
         Dim ci As New CultureInfo(supportedLanguage)
         Console.WriteLine("  {0} ({1})", supportedLanguage, ci.EnglishName)
      Next

      ' Check if current culture info language is supported
      Dim currentCulture As CultureInfo = CultureInfo.CurrentCulture
      Dim name As String = currentCulture.TwoLetterISOLanguageName
      Dim supported As Boolean = ocrEngine.LanguageManager.IsLanguageSupported(name)
      If (Not supported) Then
         name = currentCulture.Name
         supported = ocrEngine.LanguageManager.IsLanguageSupported(name)
      End If

      If (supported) Then
         Console.WriteLine("Current culture is {0}, and it is supported by this OCR engine. Enabling only this language and German now", currentCulture.EnglishName)
         ocrEngine.LanguageManager.EnableLanguages(New String() {name, "de"})

         ' If this engine does not support enabling multiple languages (currently the LEADTOOLS Advantage OCR engine), then GetEnabledLanguages
         ' will always return an array of 1, make a note of this
         If Not ocrEngine.LanguageManager.SupportsEnablingMultipleLanguages Then
            Console.WriteLine("This engine supports enabling only one language at a time, so only the first language we enabled will be used")
         End If

         Dim enabledLanguages() As String = ocrEngine.LanguageManager.GetEnabledLanguages()
         Console.WriteLine("Current enabled languages in the engine are:")
         For Each enabledLanguage As String In enabledLanguages
            ' Get the friendly name of this language using the .NET CultureInfo class
            Dim ci As New CultureInfo(enabledLanguage)
            Console.WriteLine("  {0} ({1})", enabledLanguage, ci.EnglishName)
         Next
      Else
         Console.WriteLine("Current culture is {0}, and it is not supported by this OCR engine", currentCulture.EnglishName)
      End If

      ocrEngine.Shutdown()
   End Using
End Sub
public void OcrLanguageManagerExample()
{
   // Create an instance of the engine
   using(IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Plus, false))
   {
      // Start the engine using default parameters
      ocrEngine.Startup(null, null, null, null);
      // Show languages supported by this engine
      string[] supportedLanguages = ocrEngine.LanguageManager.GetSupportedLanguages();

      Console.WriteLine("Supported languages:");
      foreach(string supportedLanguage in supportedLanguages)
      {
         // Get the friendly name of this language using the .NET CultureInfo class
         CultureInfo ci = new CultureInfo(supportedLanguage);
         Console.WriteLine("  {0} ({1})", supportedLanguage, ci.EnglishName);
      }

      // Check if current culture info language is supported
      CultureInfo currentCulture = CultureInfo.CurrentCulture;
      string name = currentCulture.TwoLetterISOLanguageName;
      bool supported = ocrEngine.LanguageManager.IsLanguageSupported(name);
      if(!supported)
      {
         name = currentCulture.Name;
         supported = ocrEngine.LanguageManager.IsLanguageSupported(name);
      }

      if(supported)
      {
         Console.WriteLine("Current culture is {0}, and it is supported by this OCR engine. Enabling only this language and German now", currentCulture.EnglishName);
         ocrEngine.LanguageManager.EnableLanguages(new string[] { name, "de" });

         // If this engine does not support enabling multiple languages (currently the LEADTOOLS Advantage OCR engine), then GetEnabledLanguages
         // will always return an array of 1, make a note of this
         if(!ocrEngine.LanguageManager.SupportsEnablingMultipleLanguages)
            Console.WriteLine("This engine supports enabling only one language at a time, so only the first language we enabled will be used");

         string[] enabledLanguages = ocrEngine.LanguageManager.GetEnabledLanguages();
         Console.WriteLine("Current enabled languages in the engine are:");
         foreach(string enabledLanguage in enabledLanguages)
         {
            // Get the friendly name of this language using the .NET CultureInfo class
            CultureInfo ci = new CultureInfo(enabledLanguage);
            Console.WriteLine("  {0} ({1})", enabledLanguage, ci.EnglishName);
         }
      }
      else
         Console.WriteLine("Current culture is {0}, and it is not supported by this OCR engine", currentCulture.EnglishName);

      ocrEngine.Shutdown();
   }
}
[TestMethod]
public void OcrLanguageManagerExample()
{
   // Create an instance of the engine
   IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false);
   // Start the engine using default parameters
   ocrEngine.Startup(null, null, String.Empty, Tools.OcrEnginePath);

   // Show languages supported by this engine
   string[] supportedLanguages = ocrEngine.LanguageManager.GetSupportedLanguages();

   Debug.WriteLine("Supported languages:");
   foreach(string supportedLanguage in supportedLanguages)
   {
      // Get the friendly name of this language using the .NET CultureInfo class
      CultureInfo ci = new CultureInfo(supportedLanguage);
      Debug.WriteLine("  {0} ({1})", supportedLanguage, ci.EnglishName);
   }

   // Check if current culture info language is supported
   CultureInfo currentCulture = CultureInfo.CurrentCulture;
   string name = currentCulture.TwoLetterISOLanguageName;
   bool supported = ocrEngine.LanguageManager.IsLanguageSupported(name);
   if(!supported)
   {
      name = currentCulture.Name;
      supported = ocrEngine.LanguageManager.IsLanguageSupported(name);
   }

   if(supported)
   {
      Debug.WriteLine("Current culture is {0}, and it is supported by this OCR engine. Enabling only this language and German now", currentCulture.EnglishName);
      ocrEngine.LanguageManager.EnableLanguages(new string[] { name, "de" });

      // If this engine does not support enabling multiple languages (currently the LEADTOOLS Advantage OCR engine), then GetEnabledLanguages
      // will always return an array of 1, make a note of this
      if(!ocrEngine.LanguageManager.SupportsEnablingMultipleLanguages)
         Debug.WriteLine("This engine supports enabling only one language at a time, so only the first language we enabled will be used");

      string[] enabledLanguages = ocrEngine.LanguageManager.GetEnabledLanguages();
      Debug.WriteLine("Current enabled languages in the engine are:");
      foreach(string enabledLanguage in enabledLanguages)
      {
         // Get the friendly name of this language using the .NET CultureInfo class
         CultureInfo ci = new CultureInfo(enabledLanguage);
         Debug.WriteLine("  {0} ({1})", enabledLanguage, ci.EnglishName);
      }
   }
   else
      Debug.WriteLine("Current culture is {0}, and it is not supported by this OCR engine", currentCulture.EnglishName);

   ocrEngine.Shutdown();
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IOcrLanguageManager Members
Leadtools.Forms.Ocr Namespace
IOcrEngine
IOcrEngine.Startup
IOcrEngine.IsStarted
IOcrEngine.Shutdown
OcrEngineManager
OcrEngineType
IOcrSettingManager
Programming with the LEADTOOLS .NET OCR
Files to be Included with Your Application
Working with OCR Languages
OCR Languages and Spell Checking

Provides access to the language environment of the character sets used by the IOcrEngine. .NET support
Object Model
IOcrLanguageManager Interface
Syntax
public interface IOcrLanguageManager 
'Declaration
 
Public Interface IOcrLanguageManager 
'Usage
 
Dim instance As IOcrLanguageManager
public interface IOcrLanguageManager 
function Leadtools.Forms.Ocr.IOcrLanguageManager() 
public interface class IOcrLanguageManager 
Remarks

You can access the instance of the IOcrLanguageManager used by an IOcrEngine through the IOcrEngine.LanguageManager property.

The language environment defines the character set(s) recognized by the OCR engine. For example, if you enable the English and German languages, the German characters (ä, Ä, é, ö, Ö, ü, Ü, ß) will be combined with the English characters to define the set recognized by the engine. The language environment does not perform spell checking however, for that, refer to IOcrSpellCheckManager.

The IOcrLanguageManager allows you to do the following:

The language values used throughout the LEADTOOLS OCR toolkit is a string value based on RFC 4646 (Windows Vista and later). The name could be an ISO 639 two-letter lowercase culture code associated with a language or a combination of ISO 630 and ISO 3166 two-letter uppercase subculture code associated with a country or region.

You must call the IOcrEngine.Startup method before you can use the IOcrEngine.LanguageManager property.

Note: The IOcrLanguageManager state is also saved when the engine settings are saved. For more information, refer to IOcrSettingManager.

Example
Copy CodeCopy Code  
Public Sub OcrLanguageManagerExample()
   ' Create an instance of the engine
   Using ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Plus, False)
      ' Start the engine using default parameters
      ocrEngine.Startup(Nothing, Nothing, Nothing, Nothing)
      ' Show languages supported by this engine
      Dim supportedLanguages() As String = ocrEngine.LanguageManager.GetSupportedLanguages()

      Console.WriteLine("Supported languages:")
      For Each supportedLanguage As String In supportedLanguages
         ' Get the friendly name of this language using the .NET CultureInfo class
         Dim ci As New CultureInfo(supportedLanguage)
         Console.WriteLine("  {0} ({1})", supportedLanguage, ci.EnglishName)
      Next

      ' Check if current culture info language is supported
      Dim currentCulture As CultureInfo = CultureInfo.CurrentCulture
      Dim name As String = currentCulture.TwoLetterISOLanguageName
      Dim supported As Boolean = ocrEngine.LanguageManager.IsLanguageSupported(name)
      If (Not supported) Then
         name = currentCulture.Name
         supported = ocrEngine.LanguageManager.IsLanguageSupported(name)
      End If

      If (supported) Then
         Console.WriteLine("Current culture is {0}, and it is supported by this OCR engine. Enabling only this language and German now", currentCulture.EnglishName)
         ocrEngine.LanguageManager.EnableLanguages(New String() {name, "de"})

         ' If this engine does not support enabling multiple languages (currently the LEADTOOLS Advantage OCR engine), then GetEnabledLanguages
         ' will always return an array of 1, make a note of this
         If Not ocrEngine.LanguageManager.SupportsEnablingMultipleLanguages Then
            Console.WriteLine("This engine supports enabling only one language at a time, so only the first language we enabled will be used")
         End If

         Dim enabledLanguages() As String = ocrEngine.LanguageManager.GetEnabledLanguages()
         Console.WriteLine("Current enabled languages in the engine are:")
         For Each enabledLanguage As String In enabledLanguages
            ' Get the friendly name of this language using the .NET CultureInfo class
            Dim ci As New CultureInfo(enabledLanguage)
            Console.WriteLine("  {0} ({1})", enabledLanguage, ci.EnglishName)
         Next
      Else
         Console.WriteLine("Current culture is {0}, and it is not supported by this OCR engine", currentCulture.EnglishName)
      End If

      ocrEngine.Shutdown()
   End Using
End Sub
public void OcrLanguageManagerExample()
{
   // Create an instance of the engine
   using(IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Plus, false))
   {
      // Start the engine using default parameters
      ocrEngine.Startup(null, null, null, null);
      // Show languages supported by this engine
      string[] supportedLanguages = ocrEngine.LanguageManager.GetSupportedLanguages();

      Console.WriteLine("Supported languages:");
      foreach(string supportedLanguage in supportedLanguages)
      {
         // Get the friendly name of this language using the .NET CultureInfo class
         CultureInfo ci = new CultureInfo(supportedLanguage);
         Console.WriteLine("  {0} ({1})", supportedLanguage, ci.EnglishName);
      }

      // Check if current culture info language is supported
      CultureInfo currentCulture = CultureInfo.CurrentCulture;
      string name = currentCulture.TwoLetterISOLanguageName;
      bool supported = ocrEngine.LanguageManager.IsLanguageSupported(name);
      if(!supported)
      {
         name = currentCulture.Name;
         supported = ocrEngine.LanguageManager.IsLanguageSupported(name);
      }

      if(supported)
      {
         Console.WriteLine("Current culture is {0}, and it is supported by this OCR engine. Enabling only this language and German now", currentCulture.EnglishName);
         ocrEngine.LanguageManager.EnableLanguages(new string[] { name, "de" });

         // If this engine does not support enabling multiple languages (currently the LEADTOOLS Advantage OCR engine), then GetEnabledLanguages
         // will always return an array of 1, make a note of this
         if(!ocrEngine.LanguageManager.SupportsEnablingMultipleLanguages)
            Console.WriteLine("This engine supports enabling only one language at a time, so only the first language we enabled will be used");

         string[] enabledLanguages = ocrEngine.LanguageManager.GetEnabledLanguages();
         Console.WriteLine("Current enabled languages in the engine are:");
         foreach(string enabledLanguage in enabledLanguages)
         {
            // Get the friendly name of this language using the .NET CultureInfo class
            CultureInfo ci = new CultureInfo(enabledLanguage);
            Console.WriteLine("  {0} ({1})", enabledLanguage, ci.EnglishName);
         }
      }
      else
         Console.WriteLine("Current culture is {0}, and it is not supported by this OCR engine", currentCulture.EnglishName);

      ocrEngine.Shutdown();
   }
}
[TestMethod]
public void OcrLanguageManagerExample()
{
   // Create an instance of the engine
   IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false);
   // Start the engine using default parameters
   ocrEngine.Startup(null, null, String.Empty, Tools.OcrEnginePath);

   // Show languages supported by this engine
   string[] supportedLanguages = ocrEngine.LanguageManager.GetSupportedLanguages();

   Debug.WriteLine("Supported languages:");
   foreach(string supportedLanguage in supportedLanguages)
   {
      // Get the friendly name of this language using the .NET CultureInfo class
      CultureInfo ci = new CultureInfo(supportedLanguage);
      Debug.WriteLine("  {0} ({1})", supportedLanguage, ci.EnglishName);
   }

   // Check if current culture info language is supported
   CultureInfo currentCulture = CultureInfo.CurrentCulture;
   string name = currentCulture.TwoLetterISOLanguageName;
   bool supported = ocrEngine.LanguageManager.IsLanguageSupported(name);
   if(!supported)
   {
      name = currentCulture.Name;
      supported = ocrEngine.LanguageManager.IsLanguageSupported(name);
   }

   if(supported)
   {
      Debug.WriteLine("Current culture is {0}, and it is supported by this OCR engine. Enabling only this language and German now", currentCulture.EnglishName);
      ocrEngine.LanguageManager.EnableLanguages(new string[] { name, "de" });

      // If this engine does not support enabling multiple languages (currently the LEADTOOLS Advantage OCR engine), then GetEnabledLanguages
      // will always return an array of 1, make a note of this
      if(!ocrEngine.LanguageManager.SupportsEnablingMultipleLanguages)
         Debug.WriteLine("This engine supports enabling only one language at a time, so only the first language we enabled will be used");

      string[] enabledLanguages = ocrEngine.LanguageManager.GetEnabledLanguages();
      Debug.WriteLine("Current enabled languages in the engine are:");
      foreach(string enabledLanguage in enabledLanguages)
      {
         // Get the friendly name of this language using the .NET CultureInfo class
         CultureInfo ci = new CultureInfo(enabledLanguage);
         Debug.WriteLine("  {0} ({1})", enabledLanguage, ci.EnglishName);
      }
   }
   else
      Debug.WriteLine("Current culture is {0}, and it is not supported by this OCR engine", currentCulture.EnglishName);

   ocrEngine.Shutdown();
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IOcrLanguageManager Members
Leadtools.Forms.Ocr Namespace
IOcrEngine
IOcrEngine.Startup
IOcrEngine.IsStarted
IOcrEngine.Shutdown
OcrEngineManager
OcrEngineType
IOcrSettingManager
Programming with the LEADTOOLS .NET OCR
Files to be Included with Your Application
Working with OCR Languages
OCR Languages and Spell Checking

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

IOcrLanguageManager requires an OCR module license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features