LEADTOOLS OCR(Leadtools.Forms.Ocrアセンブリ)

フレームを表示

IOcrLanguageManagerインターフェース








メンバ 
IOcrEngineにより用いられる文字セットの言語環境にアクセスできるようにします。
オブジェクトモデル
構文
public interface IOcrLanguageManager 
'Declaration
 
Public Interface IOcrLanguageManager 
'Usage
 
Dim instance As IOcrLanguageManager
public interface IOcrLanguageManager 
@interface LTOcrLanguageManager : NSObject
public class OcrLanguageManager
function Leadtools.Forms.Ocr.IOcrLanguageManager() 
public interface class IOcrLanguageManager 
解説

IOcrEngine.LanguageManagerプロパティを通してIOcrEngineにより用いられるIOcrLanguageManagerのインスタンスにアクセスすることができます。

言語環境は、OCRエンジンで認識される文字セットを定義します。たとえば、英語とドイツ語を有効にするならば、ドイツの文字(A、e、o、O、u、U、ss)はエンジンで認識されるセットを定義するために英語の文字と結合されます。しかし、言語環境はスペルチェックを実行しません、それのために、IOcrSpellCheckManagerを参照します。

IOcrLanguageManagerは、以下をすることができます:

値がLEADTOOLS OCRツールキットを通して使用した言語は、RFC 4646(Windows Vista以降)に基づく文字列値です。言語または3166の2-文字大文字のサブカルチャーcodeが国またはリージョンで関連付けたISO 630とISOの組合せに関連づけられる名前は、カルチャ639の2-文字小文字がコード化するISOでありえました。

IOcrEngine.LanguageManagerプロパティを使うことができる前に、IOcrEngine.Startupメソッドを呼び出さなければなりません。

注意:エンジン設定が保存されるとき、IOcrLanguageManager状態も保存されます。詳細については、「IOcrSettingManager」を参照してください。

サンプル

このサンプルはOCRエンジンでサポートされる言語を列挙して、そして現在のカルチャ言語プラスドイツ語を有効にします。

Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Forms.Ocr

<TestMethod>
Public Sub OcrLanguageManagerExample()
   ' Create an instance of the engine
   Using ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, False)
      ' Start the engine using default parameters
      ocrEngine.Startup(Nothing, Nothing, Nothing, LEAD_VARS.OcrAdvantageRuntimeDir)
      ' 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
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms.Ocr;

public void OcrLanguageManagerExample()
{
   // Create an instance of the engine
   using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false))
   {
      // Start the engine using default parameters
      ocrEngine.Startup(null, null, null, LEAD_VARS.OcrAdvantageRuntimeDir);
      // 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();
   }
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms.Ocr;

      
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();
}
必要条件

ターゲットプラットホーム

参照

参照

IOcrLanguageManagerメンバ
Leadtools.Forms.Ocr名前空間
IOcrEngine
IOcrEngine.Startup
IOcrEngine.IsStarted
IOcrEngine.Shutdown
OcrEngineManager
OcrEngineType
IOcrSettingManager
LEADTOOLS .NET OCRによるプログラミング
アプリケーションに含まれるファイル
OCR言語の操作
OCR言語とスペルチェック

Leadtools.Forms.Ocrは、認識またはDocument Imaging Suiteのライセンスと、解除キーが必要です。詳細は、以下を参照してください。LEADTOOLSツールキット機能