Divehi OCR in C# and .NET
This article was translated from English: Does it need improvement?
Translated
View the article in English
IronOCR 是一款 C# 軟體元件,讓 .NET 程式設計師能夠從 126 種語言(包括迪維希語)的圖片和 PDF 文件中讀取文字。
這是 Tesseract 的進階分支版本,專為 .NET 開發人員打造,無論在速度或準確度方面,其表現均經常優於其他 Tesseract 引擎。
IronOcr.Languages.Divehi 的內容
此套件包含 43 種適用於 .NET 的 OCR 語言:
- 迪維希語
- 迪維希語Best
- 迪維希語Fast
下載
迪維希語語言套件 [ދވހ]
安裝
首先,我們需要將 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 引擎:建立
IronTesseract(OCR 引擎)的實例。 - 指定語言:OCR 處理的語言設定為迪維希語,以確保針對該語言進行精準的辨識。
- 載入輸入:透過
OcrInput開啟圖片或 PDF 文件,準備進行文字擷取。 - 執行 OCR:
Read方法會處理輸入內容並擷取文字。 - 文字擷取:識別出的文字會儲存於
AllText並 PRINT 至控制台。
此程式碼展示了一種簡單卻強大的方法,利用 IronOCR 從數位文件中讀取迪維希文。

