Han Simplified Alphabet OCR in C# and .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English

他126の言語

IronOCR は、.NET コーダーが簡体字漢字を含む 126 の言語で画像や PDF ドキュメントからテキストを読み取ることができる C# ソフトウェア コンポーネントです。

これはTesseractの高度なフォークであり、.NET開発者専用に構築され、速度と精度の両方で他のTesseractエンジンを定期的に上回ります。

IronOcr.Languages.Han の内容

このパッケージには、.NET 用の 400 の OCR 言語が含まれています。

  • HanSimplifiedAlphabet
  • HanSimplifiedAlphabetBest
  • HanSimplifiedAlphabetFast
  • HanSimplifiedVerticalAlphabet
  • HanSimplifiedVerticalAlphabetBest
  • HanSimplifiedVerticalAlphabetFast
  • HanTraditionalAlphabet
  • HanTraditionalAlphabetBest
  • HanTraditionalAlphabetFast
  • HanTraditionalVerticalAlphabet
  • HanTraditionalVerticalAlphabetBest
  • ハングル 繁体字 縦書き アルファベット 高速

ダウンロード

簡体字漢字言語パック [Samhan]

  • Download as [Zip](javascript:window.open("/csharp/ocr/packages/language-packs/Han.ocrdata.zip")
  • NuGetでインストール

インストール

最初に、Han Simplified Alphabet OCR パッケージを .NET プロジェクトにインストールする必要があります。

パッケージ マネージャー コンソールで次のコマンドを実行します。

Install-Package IronOcr.Languages.Han

Code Example

この C# コード例は、画像または PDF ドキュメントから Han Simplified Alphabet のテキストを読み取ります。

// Reference the IronOcr library
using IronOcr;

class Program
{
    static void Main()
    {
        // Create an IronTesseract OCR engine
        var Ocr = new IronTesseract();

        // Load the Han language for OCR processing
        Ocr.Language = OcrLanguage.Han;

        // Using a 'using' statement for resource management
        using (var Input = new OcrInput(@"images\Han.png"))
        {
            // Process the image to extract text
            var Result = Ocr.Read(Input);

            // Retrieve and display the extracted text
            string AllText = Result.Text;
            System.Console.WriteLine(AllText);
        }
    }
}
// Reference the IronOcr library
using IronOcr;

class Program
{
    static void Main()
    {
        // Create an IronTesseract OCR engine
        var Ocr = new IronTesseract();

        // Load the Han language for OCR processing
        Ocr.Language = OcrLanguage.Han;

        // Using a 'using' statement for resource management
        using (var Input = new OcrInput(@"images\Han.png"))
        {
            // Process the image to extract text
            var Result = Ocr.Read(Input);

            // Retrieve and display the extracted text
            string AllText = Result.Text;
            System.Console.WriteLine(AllText);
        }
    }
}
' Reference the IronOcr library
Imports IronOcr

Friend Class Program
	Shared Sub Main()
		' Create an IronTesseract OCR engine
		Dim Ocr = New IronTesseract()

		' Load the Han language for OCR processing
		Ocr.Language = OcrLanguage.Han

		' Using a 'using' statement for resource management
		Using Input = New OcrInput("images\Han.png")
			' Process the image to extract text
			Dim Result = Ocr.Read(Input)

			' Retrieve and display the extracted text
			Dim AllText As String = Result.Text
			System.Console.WriteLine(AllText)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

説明

  • まず、IronOCRライブラリを参照して、そのOCR機能を使用します。
  • 画像やPDFドキュメントを処理するために、IronTesseractのインスタンスが作成されます。
  • OCR処理の言語は、Hanに設定されています。
  • 画像は OcrInput を使用して読み込まれ、Ocr.Read() を呼び出すことで処理されます。
  • OCR処理の結果は、ドキュメントから抽出されたテキストを含むResult.Textに保存されます。
  • 最後に、テキストをコンソールに出力します。

特にファイルストリームのような非管理リソースを扱う場合は、適切な using ディレクティブを使用し、using ステートメントを用いてリソースを効率的に管理するようにしてください。