Thai Alphabet OCR in C# and .NET
This article was translated from English: Does it need improvement?
Translated
View the article in English
本文檔的其他版本:
IronOCR是一個 C# 軟體元件,允許.NET設計師從圖像和 PDF 文件中讀取 126 種語言的文本,包括泰語字母。
它是 Tesseract 的一個高級分支,專為.NET開發人員構建,在速度和準確性方面通常優於其他 Tesseract 引擎。
IronOCR的內容。語言。泰語
此軟體包包含 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);
}
}
}
Imports IronOcr
Class ThaiOcrExample
Shared Sub Main()
' Create a new instance of IronTesseract for OCR processing
Dim ocr As 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 As 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 指定泰語語言套件進行辨識。

