Divehi OCR in C# and .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English

另外 126 種語言

IronOCR 是一個 C# 軟體元件,允許 .NET 程式設計人員從圖像和 PDF 文件中讀取包括 Divehi 在內的126種語言的文本。

它是一個專為 .NET 開發者設計的 Tesseract 高級分支,在速度和準確性方面經常優於其他 Tesseract 引擎。

IronOcr.Languages.Divehi 的內容

該套件包含43種.NET OCR語言:

  • Divehi
  • DivehiBest
  • DivehiFast

下載

Divehi 語言包 style='white-space:default'>[ދވހ]

安裝

我們需要做的第一件事是將 Divehi OCR 套件安裝到您的 .NET 專案。

Install-Package IronOCR.Languages.Divehi

代碼示例

這個 C# 代碼範例從圖像或 PDF 文件中讀取 Divehi 文本。

// 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 引擎:創建一個 IronTesseract 實例,即 OCR 引擎。
  • 指定語言:將 OCR 處理的語言設置為 Divehi,確保該語言的精確識別。
  • 加載輸入:使用 OcrInput 打開圖像或 PDF 文件,準備進行文本提取。
  • 執行 OCRRead 方法處理輸入並提取文本。
  • 文本提取:識別出的文本存儲在 AllText 中並輸出到控制台。

此代碼展示了一種簡單而強大的方式來利用 IronOCR 從數字文件中讀取 Divehi 文字。