C# 和 .NET 中的意大利语 OCR

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

意大利语 新增 125 种 OCR 语言

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

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

IronOcr.Languages.Italian 的内容

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

  • 意大利语
  • ItalianBest
  • ItalianFast
  • 意大利老
  • ItalianOldBest
  • ItalianOldFast

下载

意大利语语言包[italiano]

安装

我们首先需要做的是将意大利语OCR 包安装到您的 .NET 项目中。

Install-Package IronOCR.Languages.Italian

代码示例

这段 C# 代码示例从图像或 PDF 文档中读取意大利语文本。

// Include IronOcr library
using IronOcr;

class Program
{
    static void Main()
    {
        // Create a new instance of the IronTesseract class
        var Ocr = new IronTesseract();

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

        // Read text from an image file
        using (var Input = new OcrInput(@"images\Italian.png"))
        {
            // Perform OCR to get the text content from the image
            var Result = Ocr.Read(Input);

            // Get and print all the recognized text
            var AllText = Result.Text;
            Console.WriteLine(AllText);
        }
    }
}
// Include IronOcr library
using IronOcr;

class Program
{
    static void Main()
    {
        // Create a new instance of the IronTesseract class
        var Ocr = new IronTesseract();

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

        // Read text from an image file
        using (var Input = new OcrInput(@"images\Italian.png"))
        {
            // Perform OCR to get the text content from the image
            var Result = Ocr.Read(Input);

            // Get and print all the recognized text
            var AllText = Result.Text;
            Console.WriteLine(AllText);
        }
    }
}
' Include IronOcr library
Imports IronOcr

Friend Class Program
	Shared Sub Main()
		' Create a new instance of the IronTesseract class
		Dim Ocr = New IronTesseract()

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

		' Read text from an image file
		Using Input = New OcrInput("images\Italian.png")
			' Perform OCR to get the text content from the image
			Dim Result = Ocr.Read(Input)

			' Get and print all the recognized text
			Dim AllText = Result.Text
			Console.WriteLine(AllText)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel
  • PdfWriter:此对象负责写入PDF文件。它作用于文件路径,并写入有效PDF文档所需的结构。

1.使用 IronOCR :包含IronOcr库以利用其 OCR 功能。 2.创建 IronTesseract 实例IronTesseract是一个用于 OCR 处理的核心类。 3.设置语言:OCR 设置为处理意大利语,使用Ocr.Language = OcrLanguage.Italian 。 4.读取输入:创建一个OcrInput对象来指定图像文件。 5.执行 OCROcr.Read(Input)对输入图像执行 OCR 过程并返回文本结果。 6.输出:结果文本存储在AllText中,并在控制台中显示。

请确保images\Italian.png文件路径正确,并且该文件存在,以便示例能够正常运行。