Czech OCR in C# and .NET

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

IronOCR 是一個 C# 軟件組件,允許 .NET 程式設計師從圖像和 PDF 文檔中讀取包括捷克語在內的 126 種語言的文本。

它是 Tesseract 的高級分支,專為 .NET 開發者而建造,並且在速度和精度上經常優於其他 Tesseract 引擎。

IronOcr.Languages.Czech 的內容

此包包含 40 種 .NET 的 OCR 語言:

  • 捷克語
  • 捷克語Best
  • 捷克語Fast

下載

捷克語語言包 style='white-space:default'>[čeština]

安裝

我們首先要做的是將 捷克語 OCR 套件安裝到您的 .NET 項目中。

Install-Package IronOCR.Languages.Czech

代碼示例

此 C# 代碼示例從圖像或 PDF 文檔中讀取捷克語文本。

// Import the IronOcr namespace
using IronOcr;

class Program
{
    static void Main()
    {
        // Create a new IronTesseract instance
        var Ocr = new IronTesseract();

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

        // Define the input image or PDF and perform OCR
        using (var Input = new OcrInput(@"images\Czech.png"))
        {
            // Read the input and perform OCR
            var Result = Ocr.Read(Input);

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

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

class Program
{
    static void Main()
    {
        // Create a new IronTesseract instance
        var Ocr = new IronTesseract();

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

        // Define the input image or PDF and perform OCR
        using (var Input = new OcrInput(@"images\Czech.png"))
        {
            // Read the input and perform OCR
            var Result = Ocr.Read(Input);

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

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

Friend Class Program
	Shared Sub Main()
		' Create a new IronTesseract instance
		Dim Ocr = New IronTesseract()

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

		' Define the input image or PDF and perform OCR
		Using Input = New OcrInput("images\Czech.png")
			' Read the input and perform OCR
			Dim Result = Ocr.Read(Input)

			' Extract all recognized text
			Dim AllText = Result.Text

			' Output the recognized text to the console
			Console.WriteLine(AllText)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel
  • 上面的代碼演示了如何配置和使用 IronTesseract 類來對指定的圖像或 PDF 進行 OCR。
  • 確保在您的環境中安裝了 IronOCR.Languages.Czech 包,以便代碼正確執行。
  • OcrInput 類用於從指定路徑加載圖像,而 Ocr.Read() 則執行 OCR 操作。
  • Result.Text 將包含 OCR 輸出,該輸出在此情況下將打印到控制台。