使用 C# 和 .NET 实现西弗里斯兰语 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.WesternFrisian 的内容

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

  • 西弗里西亚人
  • WesternFrisianBest
  • 西弗里斯兰快餐

下载

西弗里西亚语语言包 [弗里西亚语]

安装

我们首先需要做的是将我们的西弗里西亚语OCR 包安装到您的 .NET 项目中。

Install-Package IronOCR.Languages.WesternFrisian

代码示例

这段 C# 代码示例从图像或 PDF 文档中读取西弗里西亚语文本。

// Import the IronOcr library
using IronOcr;

class WesternFrisianOcrExample
{
    static void Main()
    {
        // Create a new instance of IronTesseract, which is the OCR engine 
        var Ocr = new IronTesseract();

        // Set the language to Western Frisian
        Ocr.Language = OcrLanguage.WesternFrisian;

        // Perform OCR on a given image
        using (var Input = new OcrInput(@"images\WesternFrisian.png"))
        {
            // Read the input image and store the result
            var Result = Ocr.Read(Input);

            // Extract the text from the result
            string AllText = Result.Text;

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

class WesternFrisianOcrExample
{
    static void Main()
    {
        // Create a new instance of IronTesseract, which is the OCR engine 
        var Ocr = new IronTesseract();

        // Set the language to Western Frisian
        Ocr.Language = OcrLanguage.WesternFrisian;

        // Perform OCR on a given image
        using (var Input = new OcrInput(@"images\WesternFrisian.png"))
        {
            // Read the input image and store the result
            var Result = Ocr.Read(Input);

            // Extract the text from the result
            string AllText = Result.Text;

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

Friend Class WesternFrisianOcrExample
	Shared Sub Main()
		' Create a new instance of IronTesseract, which is the OCR engine 
		Dim Ocr = New IronTesseract()

		' Set the language to Western Frisian
		Ocr.Language = OcrLanguage.WesternFrisian

		' Perform OCR on a given image
		Using Input = New OcrInput("images\WesternFrisian.png")
			' Read the input image and store the result
			Dim Result = Ocr.Read(Input)

			' Extract the text from the result
			Dim AllText As String = Result.Text

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

在这个例子中,我们:

  • 初始化 OCR 引擎IronTesseract
  • 使用OcrLanguage.WesternFrisian语言选项,将 OCR 过程设置为识别西弗里西亚语文本。
  • 读取位于images\WesternFrisian.png路径的图像文件。
  • 将识别出的文本存储在AllText中,并将其打印到控制台。