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

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

  • 巽他语
  • 巽他族最佳
  • 巽他早餐

下载

巽他语语言包[巽他语]

安装

我们首先需要做的就是将我们的巽他语OCR 包安装到您的 .NET 项目中。

Install-Package IronOCR.Languages.Sundanese

代码示例

此 C# 代码示例从图像或 PDF 文档中读取巽他语文本。

// Import the IronOcr namespace
using IronOcr;

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

        // Specify the language the OCR engine should use
        Ocr.Language = OcrLanguage.Sundanese;

        // Initialize the OCR input with an image file containing Sundanese text
        using (var Input = new OcrInput(@"images\Sundanese.png"))
        {
            // Process the input and get the result
            var Result = Ocr.Read(Input);

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

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

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

        // Specify the language the OCR engine should use
        Ocr.Language = OcrLanguage.Sundanese;

        // Initialize the OCR input with an image file containing Sundanese text
        using (var Input = new OcrInput(@"images\Sundanese.png"))
        {
            // Process the input and get the result
            var Result = Ocr.Read(Input);

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

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

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

		' Specify the language the OCR engine should use
		Ocr.Language = OcrLanguage.Sundanese

		' Initialize the OCR input with an image file containing Sundanese text
		Using Input = New OcrInput("images\Sundanese.png")
			' Process the input and get the result
			Dim Result = Ocr.Read(Input)

			' Extract all recognized text from the result
			Dim AllText = Result.Text

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

解释

  • 我们首先导入IronOcr命名空间以使用其 OCR 功能。
  • 创建IronTesseract实例,作为我们的主要 OCR 引擎。
  • 我们将Language属性设置为OcrLanguage.Sundanese ,以指定引擎应该读取巽他语文本。
  • 我们创建一个OcrInput对象来指定 OCR 引擎的图像文件源。 Read方法处理输入并尝试识别文本。
  • 识别出的文本存储在AllText变量中,随后打印到控制台。

该设置允许在 .NET 环境中使用 IronOCR 库从图像中可靠地识别巽他语文本。