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 处理的语言设置为 Divehi,以确保针对该语言的准确识别。
- 加载输入: 使用
OcrInput打开图像或 PDF 文档,准备提取文本。 - 执行 OCR:
Read方法处理输入并提取文本。 - 文本提取: 识别的文本存储在
AllText中并打印到控制台。
这段代码展示了一种简单而强大的方法,利用 IronOCR 从数字文档中读取迪维希文字。
Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。