C# 和 .NET 中的拉丁字母 OCR

This article was translated from English: Does it need improvement?
Translated
View the article in English

还有126种语言

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

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

IronOcr.Languages.LatinAlphabet 的内容

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

拉丁字母 拉丁字母Best

  • 拉丁字母速记

下载

拉丁字母语言包 [latine]

安装

我们首先需要做的是将我们的拉丁字母OCR 包安装到您的 .NET 项目中。

Install-Package IronOCR.Languages.LatinAlphabet

代码示例

此 C# 代码示例从图像或 PDF 文档中读取拉丁字母文本。

// Install the IronOCR.languages.LatinAlphabet package first
using IronOcr;

var Ocr = new IronTesseract(); // Initialize IronTesseract instance

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

// Define the input image or PDF you want to read
using (var Input = new OcrInput(@"images\LatinAlphabet.png"))
{
    // Perform OCR reading on the input
    var Result = Ocr.Read(Input);

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

    // Output the recognized text
    Console.WriteLine(AllText);
}
// Install the IronOCR.languages.LatinAlphabet package first
using IronOcr;

var Ocr = new IronTesseract(); // Initialize IronTesseract instance

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

// Define the input image or PDF you want to read
using (var Input = new OcrInput(@"images\LatinAlphabet.png"))
{
    // Perform OCR reading on the input
    var Result = Ocr.Read(Input);

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

    // Output the recognized text
    Console.WriteLine(AllText);
}
' Install the IronOCR.languages.LatinAlphabet package first
Imports IronOcr

Private Ocr = New IronTesseract() ' Initialize IronTesseract instance

' Set the OCR language to LatinAlphabet
Ocr.Language = OcrLanguage.LatinAlphabet

' Define the input image or PDF you want to read
Using Input = New OcrInput("images\LatinAlphabet.png")
	' Perform OCR reading on the input
	Dim Result = Ocr.Read(Input)

	' Extract the recognized text
	Dim AllText = Result.Text

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

解释

  1. IronTesseract 初始化:初始化IronTesseract实例,该实例将处理 OCR 处理。

2.语言设置: OCR 语言设置为LatinAlphabet ,这是 IronOCR 软件包中可用的语言之一。

3.输入规范:创建一个OcrInput对象,指定要从中提取文本的图像或 PDF 的路径。

  1. OCR 执行:调用IronTesseract实例的Read方法来处理OcrInput 。 这将返回一个包含提取文本的Result对象。

5.文本提取:使用Result对象的Text属性来访问识别出的文本。

6.输出:将识别出的文本打印到控制台进行验证。

请确保OcrInput中的文件路径正确指向您的图像或 PDF 文件,以避免出现文件未找到异常。