C# 和 .NET 中的老挝语 OCR

This article was translated from English: Does it need improvement?
Translated
View the article in English
Other versions of this document:

它是 Tesseract 的一个高级分支,专为 .NET 开发人员构建,在速度和准确性方面通常优于其他 Tesseract 引擎。

  • 老挝字母快 此软件包包含多个适用于 .NET 的 OCR 语言模型:

  • 劳动 老挝最佳 老挝快报 老挝字母 老挝字母表最佳 老挝字母Fast

下载

老挝语语言包[老挝语]

安装

我们首先要做的是在您的 .NET 项目中安装老挝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
  • PdfWriter:此对象负责写入PDF文件。它作用于文件路径,并写入有效PDF文档所需的结构。
  • 此代码演示了如何配置和使用 IronOCR 来专门对老挝语执行 OCR。
  • IronTesseract是用于执行 OCR 操作的主要类。
  • 使用Ocr.Language将语言设置为老挝语。
  • OcrInput类用于加载图像或 PDF 文档以进行 OCR 处理。
  • Ocr.Read方法处理输入并返回包含识别文本的结果。 using语句确保资源在使用后被释放。 最后,将识别出的文本打印到控制台进行输出验证。