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 開發人員能夠從 126 種語言(包含拉丁字母)的圖片及 PDF 文件中讀取文字。

這是 Tesseract 的進階分支版本,專為 .NET 開發者打造,無論在速度或準確度方面,其表現均經常優於其他 Tesseract 引擎。

IronOcr.Languages.LatinAlphabet 的內容

此套件包含 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);
}
' Install the IronOCR.languages.LatinAlphabet package first
Imports IronOcr

Private 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 Input = New OcrInput("images\LatinAlphabet.png")
	' Perform OCR reading on the input
	Dim Result = Ocr.Read(Input)

	' Extract the recognized text
	Dim AllText = Result.Text

	' Output the recognized text
	Console.WriteLine(AllText)
End Using
$vbLabelText   $csharpLabel

說明

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

  2. 語言設定:OCR 語言設定為 LatinAlphabet,此為 IronOCR 套件中可用的語言之一。

  3. 輸入規格:建立一個 OcrInput 物件,指定要從中擷取文字的圖片或 PDF 檔案路徑。

  4. OCR 執行:呼叫 IronTesseract 實例的 Read 方法來處理 OcrInput。 這會返回一個 Result 物件,其中包含已擷取的文字。

  5. 文字擷取:Text 物件的 Result 屬性用於存取已識別的文字。

  6. 輸出:識別出的文字將輸出至控制台以供驗證。

請確保 OcrInput 中的檔案路徑正確指向您的圖片或 PDF 檔案,以避免發生檔案未找到的例外狀況。