使用 C# 和 .NET 進行湯加語 OCR 識別

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

還有126種語言

IronOCR 是一個 C# 軟體元件,它允許 .NET 開發人員從圖像和 PDF 文件中讀取 126 種語言(包括湯加語)的文字。 它是 Tesseract 的一個高級分支,專為 .NET 開發人員量身定制,在速度和準確性方面通常優於其他 Tesseract 引擎。

IronOcr.Languages.Tonga 的內容

此軟體包包含三個專門用於湯加語的OCR語言模型:

  • 到達的
  • 到達的Best
  • 到達的Fast

下載

湯加語語言包[湯加語語言包]

  • 下載為Zip檔。
  • 使用NuGet安裝。

安裝

若要開始使用Tonga OCR 功能,請使用以下 NuGet 指令將 Tonga OCR 套件安裝到您的 .NET 專案中:

Install-Package IronOCR.Languages.Tonga

程式碼範例

以下 C# 程式碼範例示範如何使用 IronOCR 從圖像或 PDF 文件中讀取湯加文文字。

// Include the necessary IronOcr namespace
using IronOcr;

class TongaOcrExample
{
    static void Main()
    {
        // Initialize the IronTesseract OCR engine
        var Ocr = new IronTesseract();

        // Set the OCR engine to use the Tonga language pack
        Ocr.Language = OcrLanguage.Tonga;

        // Load the input image or PDF into OcrInput
        using (var Input = new OcrInput(@"images\Tonga.png"))
        {
            // Perform OCR to read the text from the image
            var Result = Ocr.Read(Input);

            // Retrieve the full text recognition result
            var AllText = Result.Text;

            // Output the result or process further as needed
            System.Console.WriteLine(AllText);
        }
    }
}
// Include the necessary IronOcr namespace
using IronOcr;

class TongaOcrExample
{
    static void Main()
    {
        // Initialize the IronTesseract OCR engine
        var Ocr = new IronTesseract();

        // Set the OCR engine to use the Tonga language pack
        Ocr.Language = OcrLanguage.Tonga;

        // Load the input image or PDF into OcrInput
        using (var Input = new OcrInput(@"images\Tonga.png"))
        {
            // Perform OCR to read the text from the image
            var Result = Ocr.Read(Input);

            // Retrieve the full text recognition result
            var AllText = Result.Text;

            // Output the result or process further as needed
            System.Console.WriteLine(AllText);
        }
    }
}
' Include the necessary IronOcr namespace
Imports IronOcr

Friend Class TongaOcrExample
	Shared Sub Main()
		' Initialize the IronTesseract OCR engine
		Dim Ocr = New IronTesseract()

		' Set the OCR engine to use the Tonga language pack
		Ocr.Language = OcrLanguage.Tonga

		' Load the input image or PDF into OcrInput
		Using Input = New OcrInput("images\Tonga.png")
			' Perform OCR to read the text from the image
			Dim Result = Ocr.Read(Input)

			' Retrieve the full text recognition result
			Dim AllText = Result.Text

			' Output the result or process further as needed
			System.Console.WriteLine(AllText)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel
  • 此程式碼範例示範如何初始化 IronTesseract OCR 引擎並將其設定為使用湯加語。
  • 我們將指定路徑中的圖像載入到OcrInput物件中。
  • Ocr.Read()方法處理輸入以提取文本,然後我們透過Result.Text屬性檢索識別出的文本。 最後,提取的文字可以根據需要在應用程式中輸出或處理。