使用 C# 和 .NET 实现泰语字母 OCR
This article was translated from English: Does it need improvement?
TranslatedView the article in English
Other versions of this document:
IronOCR 是一个 C# 软件组件,允许 .NET 程序员从图像和 PDF 文档中读取 126 种语言的文本,包括泰语字母。
它是 Tesseract 的一个高级分支,专为 .NET 开发人员构建,在速度和准确性方面通常优于其他 Tesseract 引擎。
IronOcr.Languages.Thai 的内容
此软件包包含 96 种适用于 .NET 的 OCR 语言:
- 泰语
- ThaiBest
- ThaiFast
- 泰文字母
- ThaiAlphabetBest
- ThaiAlphabetFast
下载
泰语字母语言包[泰语]
安装
我们首先需要做的就是将我们的泰语字母OCR 包安装到您的 .NET 项目中。
Install-Package IronOCR.Languages.Thai
代码示例
这段 C# 代码示例从图像或 PDF 文档中读取泰语字母文本。
// Ensure you have installed the IronOCR.Languages.Thai package via NuGet.
// Import the IronOcr namespace to work with IronOCR classes.
using IronOcr;
class ThaiOcrExample
{
static void Main()
{
// Create a new instance of IronTesseract for OCR processing
var ocr = new IronTesseract();
// Set the language to Thai for Optical Character Recognition
ocr.Language = OcrLanguage.Thai;
// Using the 'using' statement ensures that resources are properly disposed.
using (var input = new OcrInput(@"images\Thai.png"))
{
// Perform OCR to read the text from the input image
var result = ocr.Read(input);
// Retrieve and store all recognized text from the image
string allText = result.Text;
// Optionally, you can output the text to console or log it as needed
System.Console.WriteLine(allText);
}
}
}// Ensure you have installed the IronOCR.Languages.Thai package via NuGet.
// Import the IronOcr namespace to work with IronOCR classes.
using IronOcr;
class ThaiOcrExample
{
static void Main()
{
// Create a new instance of IronTesseract for OCR processing
var ocr = new IronTesseract();
// Set the language to Thai for Optical Character Recognition
ocr.Language = OcrLanguage.Thai;
// Using the 'using' statement ensures that resources are properly disposed.
using (var input = new OcrInput(@"images\Thai.png"))
{
// Perform OCR to read the text from the input image
var result = ocr.Read(input);
// Retrieve and store all recognized text from the image
string allText = result.Text;
// Optionally, you can output the text to console or log it as needed
System.Console.WriteLine(allText);
}
}
}' Ensure you have installed the IronOCR.Languages.Thai package via NuGet.
' Import the IronOcr namespace to work with IronOCR classes.
Imports IronOcr
Friend Class ThaiOcrExample
Shared Sub Main()
' Create a new instance of IronTesseract for OCR processing
Dim ocr = New IronTesseract()
' Set the language to Thai for Optical Character Recognition
ocr.Language = OcrLanguage.Thai
' Using the 'using' statement ensures that resources are properly disposed.
Using input = New OcrInput("images\Thai.png")
' Perform OCR to read the text from the input image
Dim result = ocr.Read(input)
' Retrieve and store all recognized text from the image
Dim allText As String = result.Text
' Optionally, you can output the text to console or log it as needed
System.Console.WriteLine(allText)
End Using
End Sub
End Class$vbLabelText $csharpLabel
在这个例子中,我们从位于images夹中的名为Thai.png图像中读取泰文文本。 请务必将文件路径替换为您实际的图片位置。 OCR 语言设置为泰语,使用OcrLanguage.Thai指定用于识别的泰语语言包。





