C# 與 .NET 中的孟加拉語 OCR
Curtis Chau
已更新:
本文件的其他版本
IronOCR 是 C# 軟體元件,可讓 .NET 開發人員從影像和 PDF 文件中讀取文字,支援 126 種語言,包括孟加拉語。IronOCR 是 Tesseract 的進階分支,專為 .NET 開發人員打造,速度與準確度通常優於其他 Tesseract 引擎。
IronOcr.Languages.Bengali 的內容
此套件包含 114 種適用於 .NET 的 OCR 語言:
- Bengali
- BengaliBest
- BengaliFast
- BengaliAlphabet
- BengaliAlphabetBest
- BengaliAlphabetFast
下載
孟加拉語語言套件[Bangla]
安裝
請先在您的 .NET 專案中安裝孟加拉語 OCR 套件。
程式碼範例
這段 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 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。