C# 和 .NET 中的拉丁字母 OCR

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.Languages.LatinAlphabet 的內容

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

拉丁字母 拉丁字母Best

  • 拉丁字母速記

下載

拉丁字母語言包 [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 的路徑。

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

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

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

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