C# と .NET でのロシア語 OCR

This article was translated from English: Does it need improvement?
Translated
View the article in English
Other versions of this document:

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

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

IronOcr.Languages.Russian の内容

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

  • ロシア語
  • ロシアベスト
  • ロシアファースト

ダウンロード

ロシア語言語パック

  • Zip形式でダウンロード
  • NuGetでインストール

インストール

最初に行う必要があるのは、ロシア語OCR パッケージを .NET プロジェクトにインストールすることです。

Install-Package IronOCR.Languages.Russian

Code Example

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

// Import the IronOCR namespace
using IronOcr;

class Program
{
    static void Main()
    {
        // Initialize IronTesseract, an OCR object
        var Ocr = new IronTesseract();

        // Set the OCR language to Russian
        Ocr.Language = OcrLanguage.Russian;

        // Create an OCR input for the Russian image
        using (var Input = new OcrInput(@"images\Russian.png"))
        {
            // Perform OCR on the input image
            var Result = Ocr.Read(Input);

            // Extract all the recognized text
            var AllText = Result.Text;

            // Output the recognized text
            System.Console.WriteLine(AllText);
        }
    }
}
// Import the IronOCR namespace
using IronOcr;

class Program
{
    static void Main()
    {
        // Initialize IronTesseract, an OCR object
        var Ocr = new IronTesseract();

        // Set the OCR language to Russian
        Ocr.Language = OcrLanguage.Russian;

        // Create an OCR input for the Russian image
        using (var Input = new OcrInput(@"images\Russian.png"))
        {
            // Perform OCR on the input image
            var Result = Ocr.Read(Input);

            // Extract all the recognized text
            var AllText = Result.Text;

            // Output the recognized text
            System.Console.WriteLine(AllText);
        }
    }
}
' Import the IronOCR namespace
Imports IronOcr

Friend Class Program
	Shared Sub Main()
		' Initialize IronTesseract, an OCR object
		Dim Ocr = New IronTesseract()

		' Set the OCR language to Russian
		Ocr.Language = OcrLanguage.Russian

		' Create an OCR input for the Russian image
		Using Input = New OcrInput("images\Russian.png")
			' Perform OCR on the input image
			Dim Result = Ocr.Read(Input)

			' Extract all the recognized text
			Dim AllText = Result.Text

			' Output the recognized text
			System.Console.WriteLine(AllText)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel
  • 上記のコードは、必要な IronOCR ライブラリをインポートし、OCR タスクを実行するために使用されるクラスであるIronTesseract初期化します。
  • Ocr.Language = OcrLanguage.Russianを使用して、OCR の言語をロシア語に設定します。
  • 次に、 OcrInputクラスを使用して、指定された画像ファイルRussian.pngを開きます。
  • OcrオブジェクトのReadメソッドは、画像を処理してテキストを認識するために使用されます。
  • 最後に、 Result.Textから認識されたテキストを抽出して出力します。