Italian 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.Italian 的内容

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

  • 意大利语
  • 意大利语Best
  • 意大利语Fast
  • 意大利语老版本
  • 意大利语老版本Best
  • 意大利语老版本Fast

下载

意大利语语言包[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

解释:

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

确保images\Italian.png文件路径是正确的,并且文件存在以保证示例正常工作。