C# 與 .NET 中的孟加拉語 OCR
Curtis Chau
已更新: 2026年8月2日
本文檔的其他版本:
IronOCR 是一個 C# 軟體元件,允許 .NET 程式設計師從圖像和 PDF 文件中讀取 126 種語言(包括孟加拉語)的文字。 它是 Tesseract 的一個高級分支,專為 .NET 開發人員構建,在速度和準確性方面通常優於其他 Tesseract 引擎。
IronOcr.Languages.Bengali 的內容
此軟體包包含 114 種適用於 .NET 的 OCR 語言:
- Bengali
- BengaliBest
- BengaliFast
- BengaliAlphabet
- BengaliAlphabetBest
- BengaliAlphabetFast
下載
孟加拉語語言包[Bangla]
安裝
我們首先需要做的就是將我們的孟加拉語OCR 套件安裝到您的 .NET 專案中。
程式碼範例
這段 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.Console.WriteLine(AllText);
}
}
}' Import the IronOcr namespace
Imports IronOcr
Friend Class BengaliOcrExample
Shared Sub Main()
' Create an instance of IronTesseract
Dim Ocr = New IronTesseract()
' Specify the language for OCR
Ocr.Language = OcrLanguage.Bengali
' Process the image and extract text
Using Input = 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
System.Console.WriteLine(AllText)
End Using
End Sub
End Class' Import the IronOcr namespace
Imports IronOcr
Friend Class BengaliOcrExample
Shared Sub Main()
' Create an instance of IronTesseract
Dim Ocr = New IronTesseract()
' Specify the language for OCR
Ocr.Language = OcrLanguage.Bengali
' Process the image and extract text
Using Input = 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
System.Console.WriteLine(AllText)
End Using
End Sub
End Class說明
- 導入 IronOCR:我們首先導入
IronOcr命名空間,其中包含執行OCR操作所需的類和方法。 - 建立 IronTesseract 實例:我們建立一個
IronTesseract實例,這是執行OCR的主要類。 - 設定語言:我們使用
OcrLanguage.Bengali將OCR語言設為孟加拉語。 - OcrInput:我們指定要從中提取文字的圖像路徑。 使用
OcrInput對象載入並預處理輸入文件。 - 讀取和提取文本:使用
Read方法,我們處理影像以讀取文本內容。 文本儲存在Result.Text中。 - 輸出文本:最後,我們將提取的文本打印到控制台以驗證輸出。
Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。