使用 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 從數位文件中讀取迪維希文字。