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

此套件包含多個適用於 .NET 的 OCR 語言模型:

  • 老Best
  • 老Fast
  • 老撾字母
  • 老撾字母Best
  • 老撾字母Fast

下載

老撾語語言套件 [ພາສາລາວ]

安裝

我們首先必須在您的 .NET 專案中安裝 Lao OCR 套件。

Install-Package IronOcr.Languages.Lao

程式碼範例

此 C# 程式碼範例用於從圖片或 PDF 文件中讀取老撾語文字。

// Import the IronOcr namespace to use its OCR functionality
using IronOcr;

// Create a new IronTesseract instance
var Ocr = new IronTesseract();
// Set the OCR language to Lao
Ocr.Language = OcrLanguage.Lao;

// Use a using statement to ensure proper disposal of resources
using (var Input = new OcrInput(@"images\Lao.png"))
{
    // Perform OCR on the input image
    var Result = Ocr.Read(Input);
    // Extract all text from the OCR result
    var AllText = Result.Text;

    // Output the recognized text for verification
    Console.WriteLine(AllText);
}
// Import the IronOcr namespace to use its OCR functionality
using IronOcr;

// Create a new IronTesseract instance
var Ocr = new IronTesseract();
// Set the OCR language to Lao
Ocr.Language = OcrLanguage.Lao;

// Use a using statement to ensure proper disposal of resources
using (var Input = new OcrInput(@"images\Lao.png"))
{
    // Perform OCR on the input image
    var Result = Ocr.Read(Input);
    // Extract all text from the OCR result
    var AllText = Result.Text;

    // Output the recognized text for verification
    Console.WriteLine(AllText);
}
' Import the IronOcr namespace to use its OCR functionality
Imports IronOcr

' Create a new IronTesseract instance
Private Ocr = New IronTesseract()
' Set the OCR language to Lao
Ocr.Language = OcrLanguage.Lao

' Use a using statement to ensure proper disposal of resources
Using Input = New OcrInput("images\Lao.png")
	' Perform OCR on the input image
	Dim Result = Ocr.Read(Input)
	' Extract all text from the OCR result
	Dim AllText = Result.Text

	' Output the recognized text for verification
	Console.WriteLine(AllText)
End Using
$vbLabelText   $csharpLabel

說明:

  • 此程式碼示範如何設定並使用 IronOCR 來執行針對寮語的 OCR 辨識。
  • IronTesseract 是用於執行 OCR 操作的主要類別。
  • 語言設定為老撾語,使用 Ocr.Language
  • OcrInput 是一個用於載入圖片或 PDF 文件以進行 OCR 處理的類別。
  • Ocr.Read 方法會處理輸入內容,並返回包含已識別文字的結果。
  • using 語句可確保資源在使用後被釋放。
  • 最後,識別出的文字會被 PRINT 至控制台以供驗證。