Tonga OCR in C# and .NET

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

126 種其他語言

IronOCR 是一個 C# 軟體元件,讓 .NET 開發人員能夠從 126 種語言(包括湯加語)的圖片和 PDF 文件中讀取文字。 這是 Tesseract 的進階分支版本,專為 .NET 開發人員量身打造,無論在速度或準確度方面,其表現通常都優於其他 Tesseract 引擎。

IronOcr.Languages.Tonga 的內容

此套件包含三個專為湯加語設計的 OCR 語言模型:

  • 湯加
  • 湯加Best
  • 湯加Fast

下載

東加語語言套件 [faka Tonga]

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

Class TongaOcrExample
    Shared Sub Main()
        ' Initialize the IronTesseract OCR engine
        Dim Ocr As 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 As 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 屬性取得已識別的文字。
  • 最後,提取的文字可根據應用程式需求進行輸出或後續處理。