使用 C# 和 .NET 實現馬耳他語 OCR
Other versions of this document:
IronOCR 是一個 C# 軟體元件,允許 .NET 程式設計師從圖像和 PDF 文件中讀取 126 種語言(包括馬耳他語)的文字。
它是 Tesseract 的一個高級分支,專為 .NET 開發人員構建,在速度和準確性方面通常優於其他 Tesseract 引擎。
IronOcr.Languages.馬耳他語的內容
此軟體包包含 46 種適用於 .NET 的 OCR 語言:
- 馬耳他語
- MalteseBest
- MalteseFast
下載
馬耳他語語言包 [Malti]
安裝
我們首先需要做的就是將我們的馬耳他語OCR 套件安裝到您的 .NET 專案中。
Install-Package IronOCR.Languages.Maltese
程式碼範例
這段 C# 程式碼範例從圖像或 PDF 文件中讀取馬耳他語文字。
// Import the IronOcr namespace
using IronOcr;
class Program
{
static void Main()
{
// Initialize the IronTesseract OCR engine
var Ocr = new IronTesseract();
// Set the OCR language to Maltese
Ocr.Language = OcrLanguage.Maltese;
// Define the input image or PDF document
using (var Input = new OcrInput(@"images\Maltese.png"))
{
// Perform OCR on the input and retrieve the result
var Result = Ocr.Read(Input);
// Get all the recognized text
var AllText = Result.Text;
// Output the recognized text to the console
Console.WriteLine(AllText);
}
}
}// Import the IronOcr namespace
using IronOcr;
class Program
{
static void Main()
{
// Initialize the IronTesseract OCR engine
var Ocr = new IronTesseract();
// Set the OCR language to Maltese
Ocr.Language = OcrLanguage.Maltese;
// Define the input image or PDF document
using (var Input = new OcrInput(@"images\Maltese.png"))
{
// Perform OCR on the input and retrieve the result
var Result = Ocr.Read(Input);
// Get all the recognized text
var AllText = Result.Text;
// Output the recognized text to the console
Console.WriteLine(AllText);
}
}
}在這個例子中,IronTesseract OCR 引擎用於讀取名為Maltese.png的圖像檔案中的文字。 識別出的文字隨後會列印到控制台。 請確保圖像路徑正確,並且圖像檔案包含馬耳他語文本,以便 OCR 能夠有效運作。 using語句確保資源在不再需要時得到妥善處置。





