Welsh 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.Welsh 的內容

此套件包含三種適用於 .NET 的威爾斯語 OCR 語言版本:

  • 威爾斯語
  • 威爾斯語Best
  • 威爾斯語Fast

下載

威爾斯語語言套件 [Cymraeg]

安裝

第一步是在您的 .NET 專案中安裝 Welsh OCR 套件。

Install-Package IronOcr.Languages.Welsh

程式碼範例

此 C# 程式碼範例示範如何從圖片或 PDF 文件中讀取威爾斯語文字。

// Import the IronOcr namespace
using IronOcr;

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

        // Set the language to Welsh
        Ocr.Language = OcrLanguage.Welsh;

        // Read text from the given image
        using (var Input = new OcrInput(@"images\Welsh.png"))
        {
            // Perform OCR and get the result
            var Result = Ocr.Read(Input);

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

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

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

        // Set the language to Welsh
        Ocr.Language = OcrLanguage.Welsh;

        // Read text from the given image
        using (var Input = new OcrInput(@"images\Welsh.png"))
        {
            // Perform OCR and get the result
            var Result = Ocr.Read(Input);

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

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

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

		' Set the language to Welsh
		Ocr.Language = OcrLanguage.Welsh

		' Read text from the given image
		Using Input = New OcrInput("images\Welsh.png")
			' Perform OCR and get the result
			Dim Result = Ocr.Read(Input)

			' Extract all recognized text
			Dim AllText = Result.Text

			' Output text to the console
			Console.WriteLine(AllText)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

在此程式碼中:

  • 我們首先使用 IronOcr 命名空間來存取 OCR 功能。
  • 我們建立 IronTesseract 的實例,這是 IronOCR 提供用於執行 OCR 操作的主要類別。
  • 透過 Ocr.Language = OcrLanguage.Welsh 將 OCR 語言設定為威爾斯語。
  • 我們開啟位於 images 目錄中的 Welsh.png 圖像檔案,以進行 OCR 處理。
  • 最後,Ocr.Read(Input) 方法會從圖片中讀取文字,並將擷取的文字儲存至 AllText 中。
  • 識別出的威爾斯語文字隨後會 PRINT 至控制台。