Tonga OCR in C# and .NET
Curtis Chau
已更新: 2026年4月23日
IronOCR 是一個 C# 軟體元件,它允許 .NET 開發人員從圖像和 PDF 文件中讀取 126 種語言(包括湯加語)的文字。 它是 Tesseract 的一個高級分支,專為 .NET 開發人員量身定制,在速度和準確性方面通常優於其他 Tesseract 引擎。
IronOcr.Languages.Tonga 的內容
此軟體包包含三個專門用於湯加語的OCR語言模型:
- 到達的
- 到達的Best
- 到達的Fast
下載
湯加語語言包[湯加語語言包]
安裝
若要開始使用Tonga OCR 功能,請使用以下 NuGet 指令將 Tonga OCR 套件安裝到您的 .NET 專案中:
程式碼範例
以下 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
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' Include the necessary IronOcr namespace
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- 此程式碼範例示範如何初始化 IronTesseract OCR 引擎並將其設定為使用湯加語。
- 我們從指定路徑加載圖像到
OcrInput對象中。 Ocr.Read()方法處理輸入以提取文本,然後通過Result.Text屬性檢索識別的文本。- 最後,提取的文本可以在應用程式中根據需要輸出或處理。
Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。