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

此软件包包含三个版本的威尔士语 OCR 语言,适用于 .NET:

威尔士语

  • 威尔士最佳
  • 威尔士快车

下载

威尔士语包[威尔士语]

安装

第一步是在您的 .NET 项目中安装威尔士语OCR 包。

Install-Package IronOCR.Languages.Welsh

代码示例

此 C# 代码示例演示了如何从图像或 PDF 文档中读取威尔士语文本。

// Import the IronOcr namespace
using IronOcr;

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

        // Set the language to Welsh
        Ocr.Language = OcrLanguage.Welsh;

        // Read text from the given image
        using (var Input = new OcrInput(@"images\Welsh.png"))
        {
            // Perform OCR and get the result
            var Result = Ocr.Read(Input);

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

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

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

        // Set the language to Welsh
        Ocr.Language = OcrLanguage.Welsh;

        // Read text from the given image
        using (var Input = new OcrInput(@"images\Welsh.png"))
        {
            // Perform OCR and get the result
            var Result = Ocr.Read(Input);

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

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

Friend Class Program
	Shared Sub Main()
		' Create an instance of IronTesseract
		Dim Ocr = New IronTesseract()

		' Set the language to Welsh
		Ocr.Language = OcrLanguage.Welsh

		' Read text from the given image
		Using Input = New OcrInput("images\Welsh.png")
			' Perform OCR and get the result
			Dim Result = Ocr.Read(Input)

			' Extract all recognized text
			Dim AllText = Result.Text

			' Output text to the console
			Console.WriteLine(AllText)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

在此代码中:

  • 我们首先使用IronOcr命名空间来访问 OCR 功能。
  • 我们创建IronTesseract的一个实例,它是 IronOCR 提供用于执行 OCR 操作的主要类。
  • OCR 语言设置为威尔士语,使用Ocr.Language = OcrLanguage.Welsh
  • 我们打开位于images目录中的名为Welsh.png的图像文件进行 OCR 处理。 最后, Ocr.Read(Input)方法从图像中读取文本,并将提取的文本存储在AllText中。
  • 然后,将识别出的威尔士语文本打印到控制台上。