Bengali OCR in C# and .NET
本文件的其他版本:
IronOCR 是一款 C# 軟體元件,讓 .NET 程式設計師能夠從 126 種語言(包括孟加拉語)的圖片和 PDF 文件中讀取文字。 這是 Tesseract 的進階分支版本,專為 .NET 開發人員打造,無論在速度或準確度方面,其表現均經常優於其他 Tesseract 引擎。
IronOcr.Languages.Bengali 的內容
此套件包含 114 種適用於 .NET 的 OCR 語言:
- 孟加拉語
- 孟加拉語Best
- 孟加拉語Fast
- 孟加拉語字母
- 孟加拉語字母Best
- 孟加拉語字母Fast
下載
孟加拉語語言套件 [Bangla]
安裝
我們首先必須將孟加拉語 OCR 套件安裝至您的 .NET 專案中。
Install-Package IronOcr.Languages.Bengali
程式碼範例
此 C# 程式碼範例用於從圖片或 PDF 文件中讀取孟加拉語文字。
// Import the IronOcr namespace
using IronOcr;
class BengaliOcrExample
{
static void Main()
{
// Create an instance of IronTesseract
var Ocr = new IronTesseract();
// Specify the language for OCR
Ocr.Language = OcrLanguage.Bengali;
// Process the image and extract text
using (var Input = new OcrInput(@"images\Bengali.png"))
{
// Perform OCR on the input image
var Result = Ocr.Read(Input);
// Get the extracted text
var AllText = Result.Text;
// Output the extracted text to the console
System.Co/nsole.WriteLine(AllText);
}
}
}
// Import the IronOcr namespace
using IronOcr;
class BengaliOcrExample
{
static void Main()
{
// Create an instance of IronTesseract
var Ocr = new IronTesseract();
// Specify the language for OCR
Ocr.Language = OcrLanguage.Bengali;
// Process the image and extract text
using (var Input = new OcrInput(@"images\Bengali.png"))
{
// Perform OCR on the input image
var Result = Ocr.Read(Input);
// Get the extracted text
var AllText = Result.Text;
// Output the extracted text to the console
System.Co/nsole.WriteLine(AllText);
}
}
}
Imports IronOcr
Class BengaliOcrExample
Shared Sub Main()
' Create an instance of IronTesseract
Dim Ocr As New IronTesseract()
' Specify the language for OCR
Ocr.Language = OcrLanguage.Bengali
' Process the image and extract text
Using Input As New OcrInput("images\Bengali.png")
' Perform OCR on the input image
Dim Result = Ocr.Read(Input)
' Get the extracted text
Dim AllText = Result.Text
' Output the extracted text to the console
Console.WriteLine(AllText)
End Using
End Sub
End Class
說明
-
導入 IronOCR:我們首先導入
IronOcr命名空間,其中包含執行 OCR 操作所需的類別與方法。 -
建立 IronTesseract 實例:我們建立
IronTesseract的實例,這是用於執行 OCR 的主要類別。 -
設定語言:我們使用
OcrLanguage.Bengali將 OCR 語言設定為孟加拉語。 -
OcrInput:我們指定要從中擷取文字的圖片路徑。 使用
OcrInput物件來載入並預處理輸入檔案。 -
讀取並擷取文字:透過
Read方法,我們處理圖像以讀取其中的文字內容。 原始文字儲存於Result.Text中。 - 輸出文字:最後,我們將擷取的文字PRINT至控制台以驗證結果。

