Panjabi OCR in C# and .NET
Curtis Chau
已更新: 2026年8月2日
本文檔的其他版本:
IronOCR 是一個 C# 軟體元件,允許 .NET 程式設計師從圖像和 PDF 文件中讀取 126 種語言(包括旁遮普語)的文字。 它是 Tesseract 的一個高級分支,專為 .NET 開發人員構建,在速度和準確性方面通常優於其他 Tesseract 引擎。
IronOcr.Languages.Panjabi 的內容
此軟體包包含 46 種適用於 .NET 的 OCR 語言:
- 潘賈比
- 潘賈比Best
- 潘賈比Fast
下載
旁遮普語語言包[旁遮普語]
安裝
我們首先需要做的就是將Panjabi OCR 套件安裝到您的 .NET 專案中。
程式碼範例
此 C# 程式碼範例從圖像或 PDF 文件中讀取旁遮普語文字。
// Import the IronOcr namespace
using IronOcr;
class Program
{
static void Main()
{
// Create a new instance of the IronTesseract class
var Ocr = new IronTesseract();
// Set the language to Panjabi
Ocr.Language = OcrLanguage.Panjabi;
// Define the input image or PDF file
using (var Input = new OcrInput(@"images\Panjabi.png"))
{
// Perform OCR on the input file
var Result = Ocr.Read(Input);
// Extract and store the recognized text from the OCR result
var AllText = Result.Text;
}
}
}' Import the IronOcr namespace
Imports IronOcr
Module Program
Sub Main()
' Create a new instance of the IronTesseract class
Dim Ocr As New IronTesseract()
' Set the language to Panjabi
Ocr.Language = OcrLanguage.Panjabi
' Define the input image or PDF file
Using Input As New OcrInput("images\Panjabi.png")
' Perform OCR on the input file
Dim Result = Ocr.Read(Input)
' Extract and store the recognized text from the OCR result
Dim AllText = Result.Text
End Using
End Sub
End Module' Import the IronOcr namespace
Imports IronOcr
Module Program
Sub Main()
' Create a new instance of the IronTesseract class
Dim Ocr As New IronTesseract()
' Set the language to Panjabi
Ocr.Language = OcrLanguage.Panjabi
' Define the input image or PDF file
Using Input As New OcrInput("images\Panjabi.png")
' Perform OCR on the input file
Dim Result = Ocr.Read(Input)
' Extract and store the recognized text from the OCR result
Dim AllText = Result.Text
End Using
End Sub
End Module說明
- IronTesseract: 這是IronOCR提供的進行OCR操作的主要類別。
- Ocr.Language: 我們指定OCR引擎應該使用的語言。 這裡,語言設定為旁遮普語。
- OcrInput: 此類別用於指定需要進行OCR的輸入檔案(圖像或PDF)。
Ocr.Read(): 此方法執行實際的OCR任務,並返回包含提取文本的結果。- Result.Text: 這包含OCR在輸入檔案上執行後提取的文本。
本範例示範如何在 .NET 應用程式中有效地使用 IronOCR 程式庫從圖像或 PDF 文件中提取旁遮普文字。
Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。