Russian OCR in C# and .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English
本文件的其他版本:

IronOCR 是一款 C# 軟體元件,讓 .NET 開發人員能夠從 126 種語言(包括俄語)的圖片和 PDF 文件中讀取文字。

這是 Tesseract 的進階分支版本,專為 .NET 開發者打造,無論在速度或準確度方面,其表現均定期超越其他 Tesseract 引擎。

IronOcr.Languages.Russian 內容

此套件包含 46 種適用於 .NET 的 OCR 語言:

  • 俄文
  • 俄文Best
  • 俄文Fast

下載

俄語語言套件 [русский язык]

安裝

我們首先必須將俄語 OCR 套件安裝至您的 .NET 專案中。

Install-Package IronOcr.Languages.Russian

程式碼範例

此 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.Co/nsole.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.Co/nsole.WriteLine(AllText);
        }
    }
}
Imports IronOcr

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

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

        ' Create an OCR input for the Russian image
        Using Input As 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程式庫,並初始化 IronTesseract,這是一個用於執行 OCR 任務的類別。
  • 它使用 Ocr.Language = OcrLanguage.Russian 將 OCR 的語言設定為俄文。
  • 接著,它會使用 OcrInput 類別開啟指定的圖片檔案 Russian.png
  • Read 物件的 Ocr 方法用於處理影像並識別文字。
  • 最後,它會從 Result.Text 中提取已識別的文字並輸出。