使用 C# 和 .NET 进行 OCR 翻译
This article was translated from English: Does it need improvement?
TranslatedView the article in English
IronOCR 是一个 C# 软件组件,允许 .NET 程序员从图像和 PDF 文档中读取 126 种语言的文本,包括提格雷语。 它是 Tesseract 的一个高级分支,专为 .NET 开发人员构建,在速度和准确性方面通常优于其他 Tesseract 引擎。
IronOcr.Languages.Tigrinya 的内容
此软件包包含 49 种适用于 .NET 的 OCR 语言:
提格里尼亚语 提格里尼亚语Best -TigrinyaFast
下载
提格里尼亚语语言包[提格里尼亚语]
下载为Zip 文件
- 使用NuGet安装
安装
我们首先需要做的是将Tigrinya OCR 包安装到您的 .NET 项目中。
Install-Package IronOCR.Languages.Tigrinya
代码示例
这段 C# 代码示例从图像或 PDF 文档中读取提格雷尼亚语文本。
using IronOcr;
class Program
{
static void Main()
{
// Create a new instance of IronTesseract to perform OCR
var Ocr = new IronTesseract();
// Set the OCR language to Tigrinya
Ocr.Language = OcrLanguage.Tigrinya;
// Using statement ensures the OcrInput object is disposed of after use
using (var Input = new OcrInput(@"images\Tigrinya.png"))
{
// Perform OCR on the input image
var Result = Ocr.Read(Input);
// Extract all text recognized in the image and store it in a variable
var AllText = Result.Text;
// Output the extracted text
Console.WriteLine(AllText);
}
}
}using IronOcr;
class Program
{
static void Main()
{
// Create a new instance of IronTesseract to perform OCR
var Ocr = new IronTesseract();
// Set the OCR language to Tigrinya
Ocr.Language = OcrLanguage.Tigrinya;
// Using statement ensures the OcrInput object is disposed of after use
using (var Input = new OcrInput(@"images\Tigrinya.png"))
{
// Perform OCR on the input image
var Result = Ocr.Read(Input);
// Extract all text recognized in the image and store it in a variable
var AllText = Result.Text;
// Output the extracted text
Console.WriteLine(AllText);
}
}
}Imports IronOcr
Friend Class Program
Shared Sub Main()
' Create a new instance of IronTesseract to perform OCR
Dim Ocr = New IronTesseract()
' Set the OCR language to Tigrinya
Ocr.Language = OcrLanguage.Tigrinya
' Using statement ensures the OcrInput object is disposed of after use
Using Input = New OcrInput("images\Tigrinya.png")
' Perform OCR on the input image
Dim Result = Ocr.Read(Input)
' Extract all text recognized in the image and store it in a variable
Dim AllText = Result.Text
' Output the extracted text
Console.WriteLine(AllText)
End Using
End Sub
End Class$vbLabelText $csharpLabel
解释
- IronTesseract :这是 IronOCR 中的一个专门用于执行文本识别的类。
- Ocr.Language :设置 OCR 引擎使用的语言。在本例中,它设置为提格雷尼亚语。
- OcrInput :表示输入源,在本例中为图像,将转换为文本。
- Ocr.Read(Input) : 对指定的输入执行 OCR 并返回结果。
- Result.Text :包含从输入图像经过 OCR 处理后提取的文本。
- Console.WriteLine(AllText) : 将提取的文本输出到控制台。 这行代码是可选的,如果不需要控制台输出,可以删除。





