C# 與 .NET 中的迪維希語 OCR
Curtis Chau
已更新: 2026年8月2日
IronOCR 是一個 C# 軟體元件,允許 .NET 程式設計師從圖像和 PDF 文件中讀取 126 種語言(包括迪維希語)的文字。
它是 Tesseract 的一個高級分支,專為 .NET 開發人員構建,在速度和準確性方面通常優於其他 Tesseract 引擎。
IronOcr.Languages.Divehi 的內容
此軟體包包含 43 種適用於 .NET 的 OCR 語言:
- Divehi
- DivehiBest
- DivehiFast
下載
迪維希語包[月曆法優]
安裝
我們需要做的第一件事是將Divehi OCR 套件安裝到您的 .NET 專案中。
程式碼範例
此 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
Imports IronOcr
Module Program
Sub Main()
' Create an instance of the IronTesseract OCR engine
Dim Ocr As New IronTesseract()
' Set the OCR language to Divehi
Ocr.Language = OcrLanguage.Divehi
' Load the image or PDF document into the OCR processor
Using Input As 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 Module' Import the IronOcr namespace
Imports IronOcr
Module Program
Sub Main()
' Create an instance of the IronTesseract OCR engine
Dim Ocr As New IronTesseract()
' Set the OCR language to Divehi
Ocr.Language = OcrLanguage.Divehi
' Load the image or PDF document into the OCR processor
Using Input As 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 Module說明
- 導入IronOCR: 示例首先導入必要的IronOCR命名空間。
- 建立OCR引擎: 建立了
IronTesseract的實例,即OCR引擎。 - 指定語言: OCR處理的語言設置為迪維希語,確保針對該語言進行準確識別。
- 載入輸入: 使用
OcrInput打開一個圖像或PDF文件,準備進行文字提取。 - 執行OCR:
Read方法處理輸入並提取文本。 - 文字提取: 識別的文本存儲在
AllText中,並打印到控制台。
這段程式碼展示了一種簡單而強大的方法,利用 IronOCR 從數位文件中讀取迪維希文字。
Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。