C# 和 .NET 中的旁遮普語 OCR
This article was translated from English: Does it need improvement?
TranslatedView the article in English
Other versions of this document:
IronOCR 是一個 C# 軟體元件,允許 .NET 程式設計師從圖像和 PDF 文件中讀取 126 種語言(包括旁遮普語)的文字。 它是 Tesseract 的一個高級分支,專為 .NET 開發人員構建,在速度和準確性方面通常優於其他 Tesseract 引擎。
IronOcr.Languages.Panjabi 的內容
此軟體包包含 46 種適用於 .NET 的 OCR 語言:
- 旁遮普語
- PanjabiBest
- PanjabiFast
下載
旁遮普語語言包[旁遮普語]
安裝
我們首先需要做的就是將Panjabi OCR 套件安裝到您的 .NET 專案中。
Install-Package IronOCR.Languages.Panjabi
程式碼範例
此 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
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
Friend Class Program
Shared Sub Main()
' Create a new instance of the IronTesseract class
Dim Ocr = New IronTesseract()
' Set the language to Panjabi
Ocr.Language = OcrLanguage.Panjabi
' Define the input image or PDF file
Using Input = 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 Class$vbLabelText $csharpLabel
說明
- IronTesseract :這是 IronOCR 為 OCR 操作提供的主要類別。
- Ocr.Language :我們指定 OCR 引擎應使用的語言。 這裡,語言設定為旁遮普語。
- OcrInput :此類別用於指定要執行 OCR 的輸入檔案(影像或 PDF)。
- Ocr.Read() :此方法執行實際的 OCR 任務並傳回包含擷取文字的結果。
- Result.Text :包含對輸入檔執行 OCR 後擷取的文字。
本範例示範如何在 .NET 應用程式中有效地使用 IronOCR 程式庫從圖像或 PDF 文件中提取旁遮普文本。





