Lao OCR in C# and .NET
Curtis Chau
已更新: 2026年8月2日
本文檔的其他版本:
IronOCR 是一個 C# 軟體元件,允許 .NET 程式設計師從圖像和 PDF 文件中讀取 126 種語言(包括寮語)的文字。
它是 Tesseract 的一個高級分支,專為 .NET 開發人員構建,在速度和準確性方面通常優於其他 Tesseract 引擎。
IronOcr.Languages.Lao 的內容
此軟體包包含多個適用於 .NET 的 OCR 語言模型:
- 勞動
- 勞動Best
- 勞動Fast
- 勞動Alphabet
- 勞動AlphabetBest
- 勞動AlphabetFast
下載
寮語語言包[寮語]
安裝
我們首先要做的是在您的 .NET 專案中安裝寮國OCR 套件。
程式碼範例
此 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
Imports IronOcr
' Create a new IronTesseract instance
Dim Ocr As New IronTesseract()
' Set the OCR language to Lao
Ocr.Language = OcrLanguage.Lao
' Use a using block to ensure proper disposal of resources
Using Input As 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' Import the IronOcr namespace to use its OCR functionality
Imports IronOcr
' Create a new IronTesseract instance
Dim Ocr As New IronTesseract()
' Set the OCR language to Lao
Ocr.Language = OcrLanguage.Lao
' Use a using block to ensure proper disposal of resources
Using Input As 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說明:
- 此程式碼演示了如何配置和使用IronOCR來對寮國語言進行OCR。
IronTesseract是用於進行OCR操作的主要類別。- 使用
Ocr.Language將語言設置為寮國語。 OcrInput是用於加載圖像或PDF文件以進行OCR處理的類別。Ocr.Read方法處理輸入並返回包含識別文本的結果。using語句確保資源在使用後釋放。- 最後,識別的文本將打印到控制台以驗證輸出。
Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。