Latin Alphabet OCR in C# and .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English

還有126種語言

IronOCR是一個 C# 軟體元件,允許.NET設計師從圖像和 PDF 文件中讀取 126 種語言(包括拉丁字母)的文字。

它是 Tesseract 的一個高級分支,專為.NET開發人員構建,在速度和準確性方面通常優於其他 Tesseract 引擎。

IronOCR的內容.語言.拉丁字母

此軟體包包含 64 種適用於.NET的 OCR 語言:

拉丁字母 拉丁字母Best 拉丁字母Fast

下載

拉丁字母語言包 [latine]

安裝

我們首先需要做的是將我們的拉丁字母OCR 套件安裝到您的.NET專案中。

Install-Package IronOcr.Languages.LatinAlphabet

程式碼範例

此 C# 程式碼範例從圖像或 PDF 文件中讀取拉丁字母文字。

// Install the IronOCR.languages.LatinAlphabet package first
using IronOcr;

var Ocr = new IronTesseract(); // Initialize IronTesseract instance

// Set the OCR language to LatinAlphabet
Ocr.Language = OcrLanguage.LatinAlphabet;

// Define the input image or PDF you want to read
using (var Input = new OcrInput(@"images\LatinAlphabet.png"))
{
    // Perform OCR reading on the input
    var Result = Ocr.Read(Input);

    // Extract the recognized text
    var AllText = Result.Text;

    // Output the recognized text
    Console.WriteLine(AllText);
}
// Install the IronOCR.languages.LatinAlphabet package first
using IronOcr;

var Ocr = new IronTesseract(); // Initialize IronTesseract instance

// Set the OCR language to LatinAlphabet
Ocr.Language = OcrLanguage.LatinAlphabet;

// Define the input image or PDF you want to read
using (var Input = new OcrInput(@"images\LatinAlphabet.png"))
{
    // Perform OCR reading on the input
    var Result = Ocr.Read(Input);

    // Extract the recognized text
    var AllText = Result.Text;

    // Output the recognized text
    Console.WriteLine(AllText);
}
$vbLabelText   $csharpLabel

解釋

  1. IronTesseract 初始化:初始化 IronTesseract 的實例,該實例將處理 OCR 處理。

2.語言設定: OCR 語言設定為 LatinAlphabet,這是IronOCR軟體包中可用的語言之一。

3.輸入規格:建立一個 OcrInput 對象,指定要從中提取文字的圖像或 PDF 的路徑。

  1. OCR 執行:呼叫 Read 實例的 IronTesseract 方法來處理 OcrInput。 這將傳回一個包含提取文字的 Result 物件。

5.文字擷取:使用 Text 物件的 Result 屬性來存取辨識的文字。

6.輸出:將識別出的文字列印到控制台進行驗證。

請確保 OcrInput 中的文件路徑正確指向您的圖像或 PDF 文件,以避免文件未找到異常。