C# 中的西里尔字母 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.Cyrillic 的内容

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

  • 西里尔字母
  • 西里尔字母最佳
  • CyrillicAlphabetFast

下载

西里尔字母语言包[西里尔字母脚本]

安装

首先,您需要将西里尔字母OCR 包安装到您的 .NET 项目中。

Install-Package IronOCR.Languages.Cyrillic

代码示例

这段 C# 代码示例从图像或 PDF 文档中读取西里尔字母文本。

using IronOcr;

public class OcrExample
{
    public void ReadCyrillicText()
    {
        // Initialize a new instance of the IronTesseract OCR engine
        var Ocr = new IronTesseract();

        // Set the OCR engine to use the Cyrillic language package
        Ocr.Language = OcrLanguage.Cyrillic;

        // Create a new OCR input from an image file
        using (var Input = new OcrInput(@"images\Cyrillic.png"))
        {
            // Read the image using the OCR engine
            var Result = Ocr.Read(Input);

            // Retrieve Recognized Text
            var AllText = Result.Text;

            // Output the recognized text to the console
            Console.WriteLine(AllText);
        }
    }
}
using IronOcr;

public class OcrExample
{
    public void ReadCyrillicText()
    {
        // Initialize a new instance of the IronTesseract OCR engine
        var Ocr = new IronTesseract();

        // Set the OCR engine to use the Cyrillic language package
        Ocr.Language = OcrLanguage.Cyrillic;

        // Create a new OCR input from an image file
        using (var Input = new OcrInput(@"images\Cyrillic.png"))
        {
            // Read the image using the OCR engine
            var Result = Ocr.Read(Input);

            // Retrieve Recognized Text
            var AllText = Result.Text;

            // Output the recognized text to the console
            Console.WriteLine(AllText);
        }
    }
}
Imports IronOcr

Public Class OcrExample
	Public Sub ReadCyrillicText()
		' Initialize a new instance of the IronTesseract OCR engine
		Dim Ocr = New IronTesseract()

		' Set the OCR engine to use the Cyrillic language package
		Ocr.Language = OcrLanguage.Cyrillic

		' Create a new OCR input from an image file
		Using Input = New OcrInput("images\Cyrillic.png")
			' Read the image using the OCR engine
			Dim Result = Ocr.Read(Input)

			' Retrieve Recognized Text
			Dim AllText = Result.Text

			' Output the recognized text to the console
			Console.WriteLine(AllText)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel
  • IronTesseract :这是用于配置和执行 OCR 任务的 OCR 引擎类。
  • OcrInput :表示要执行 OCR 的输入图像或文档的类。
  • OcrLanguage.Cyrillic :指定 OCR 引擎应使用西里尔语语言包进行识别。
  • Result.Text :从 OCR 结果对象中访问已识别的文本。

本示例演示了一个简单的用例,即处理带有西里尔字母的图像以提取文本。