Vietnamese OCR in C# and .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English
本文档的其他版本:

越南语 新增 125 种 OCR 语言

IronOCR 是一个 C# 软件组件,允许 .NET 程序员从图像和 PDF 文档中读取 126 种语言(包括越南语)的文本。

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

IronOcr.Languages.Vietnamese 的内容

此软件包包含 132 种适用于 .NET 的 OCR 语言:

  • 越南语
  • VietnameseBest
  • VietnameseFast
  • 越南语字母
  • VietnameseAlphabetBest
  • VietnameseAlphabetFast

下载

越南语语言包

安装

我们首先需要做的就是将我们的越南语OCR 包安装到您的 .NET 项目中。

Install-Package IronOcr.Languages.Vietnamese

代码示例

此 C# 代码示例从图像或 PDF 文档中读取越南语文本。

// You need to install the IronOcr.Languages.Vietnamese package using the following NuGet command before running this code:
// PM> Install-Package IronOcr.Languages.Vietnamese

using IronOcr;

var Ocr = new IronTesseract();

// Set the OCR language to Vietnamese
Ocr.Language = OcrLanguage.Vietnamese;

using (var Input = new OcrInput(@"images\Vietnamese.png"))
{
    // Perform OCR on the input image
    var Result = Ocr.Read(Input);

    // Extract all recognized text
    var AllText = Result.Text;

    // Example: Output the extracted text to the console
    Console.WriteLine(AllText);
}
// You need to install the IronOcr.Languages.Vietnamese package using the following NuGet command before running this code:
// PM> Install-Package IronOcr.Languages.Vietnamese

using IronOcr;

var Ocr = new IronTesseract();

// Set the OCR language to Vietnamese
Ocr.Language = OcrLanguage.Vietnamese;

using (var Input = new OcrInput(@"images\Vietnamese.png"))
{
    // Perform OCR on the input image
    var Result = Ocr.Read(Input);

    // Extract all recognized text
    var AllText = Result.Text;

    // Example: Output the extracted text to the console
    Console.WriteLine(AllText);
}
$vbLabelText   $csharpLabel

在此代码示例中:

  • 我们创建了 IronTesseract 的实例。
  • 使用 Ocr.Language = OcrLanguage.Vietnamese; 将语言设置为越南语。
  • 创建一个 OcrInput 对象,并传入图像或 PDF 的路径。
  • 调用 Read 方法执行 OCR 并获取提取的文本。
  • 提取的文本存储在 AllText 中,可以根据需要使用,例如显示或保存到文件中。