使用 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.Latvian 的內容
此軟體包包含 46 種適用於 .NET 的 OCR 語言:
- 拉脫維亞語
- LatvianBest
- LatvianFast
下載
拉脫維亞語語言包[拉脫維亞語]
安裝
首先,你需要將拉脫維亞語OCR 套件安裝到你的 .NET 專案中。
Install-Package IronOCR.Languages.Latvian
程式碼範例
這段 C# 程式碼範例從圖像或 PDF 文件中讀取拉脫維亞文本。
using IronOcr;
class LatvianOCRExample
{
static void Main()
{
// Create an instance of IronTesseract for OCR
var Ocr = new IronTesseract();
// Set the OCR language to Latvian
Ocr.Language = OcrLanguage.Latvian;
// Define the input image file path
using (var Input = new OcrInput(@"images\Latvian.png"))
{
// Perform OCR on the input image
var Result = Ocr.Read(Input);
// Extract all recognized text from the OCR result
var AllText = Result.Text;
// Output the recognized text to the console
Console.WriteLine(AllText);
}
}
}using IronOcr;
class LatvianOCRExample
{
static void Main()
{
// Create an instance of IronTesseract for OCR
var Ocr = new IronTesseract();
// Set the OCR language to Latvian
Ocr.Language = OcrLanguage.Latvian;
// Define the input image file path
using (var Input = new OcrInput(@"images\Latvian.png"))
{
// Perform OCR on the input image
var Result = Ocr.Read(Input);
// Extract all recognized text from the OCR result
var AllText = Result.Text;
// Output the recognized text to the console
Console.WriteLine(AllText);
}
}
}Imports IronOcr
Friend Class LatvianOCRExample
Shared Sub Main()
' Create an instance of IronTesseract for OCR
Dim Ocr = New IronTesseract()
' Set the OCR language to Latvian
Ocr.Language = OcrLanguage.Latvian
' Define the input image file path
Using Input = New OcrInput("images\Latvian.png")
' Perform OCR on the input image
Dim Result = Ocr.Read(Input)
' Extract all recognized text from the OCR result
Dim AllText = Result.Text
' Output the recognized text to the console
Console.WriteLine(AllText)
End Using
End Sub
End Class$vbLabelText $csharpLabel
說明
- IronOcr 命名空間:範例首先匯入
IronOcr命名空間,這是存取 OCR 功能所必需的。 - IronTesseract 實例:建立
IronTesseract物件(Ocr)是為了處理影像讀取和文字擷取。 -語言配置:透過設定Ocr.Language屬性,將 OCR 過程配置為讀取拉脫維亞語文字。 - OcrInput 物件:建立一個
OcrInput對象,引用要處理的映像檔。 -讀取圖像:呼叫Ocr實例的Read方法來處理圖像並提取文本,並將文本儲存在Result變數中。 -結果擷取:透過Result.Text存取 OCR 結果,並將其儲存在AllText中以供進一步使用或顯示。 -控制台輸出:辨識出的拉脫維亞文字會印到控制台上,從而提供文字擷取的視覺確認。





