使用 C# 和 .NET 进行 Divehi 语 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.Divehi 的内容

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

迪维希 迪维希Best 迪维希Fast

下载

迪维希语包[ދވހ]

下载为Zip 文件

安装

我们需要做的第一件事是将Divehi OCR 包安装到您的 .NET 项目中。

Install-Package IronOCR.Languages.Divehi

代码示例

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

// Import the IronOcr namespace
using IronOcr;

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

        // Set the OCR language to Divehi
        Ocr.Language = OcrLanguage.Divehi;

        // Load the image or PDF document into the OCR processor
        using (var Input = new OcrInput(@"images\Divehi.png"))
        {
            // Perform OCR on the input document
            var Result = Ocr.Read(Input);

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

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

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

        // Set the OCR language to Divehi
        Ocr.Language = OcrLanguage.Divehi;

        // Load the image or PDF document into the OCR processor
        using (var Input = new OcrInput(@"images\Divehi.png"))
        {
            // Perform OCR on the input document
            var Result = Ocr.Read(Input);

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

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

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

		' Set the OCR language to Divehi
		Ocr.Language = OcrLanguage.Divehi

		' Load the image or PDF document into the OCR processor
		Using Input = New OcrInput("images\Divehi.png")
			' Perform OCR on the input document
			Dim Result = Ocr.Read(Input)

			' Extract all recognized text
			Dim AllText = Result.Text

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

解释

-导入 IronOcr :示例首先导入必要的 IronOcr 命名空间。 -创建 OCR 引擎:创建 OCR 引擎IronTesseract的一个实例。 -指定语言:OCR 处理的语言设置为迪维希语,确保针对该语言进行准确识别。 -加载输入:使用OcrInput打开图像或 PDF 文档,准备提取文本。 -执行 OCRRead方法处理输入并提取文本。 -文本提取:识别出的文本存储在AllText中,并打印到控制台。

这段代码展示了一种简单而强大的方法,利用 IronOCR 从数字文档中读取迪维希文字。