Latvian OCR in C# and .NET
Curtis Chau
已更新: 2026年8月2日
本文檔的其他版本:
IronOCR 是一個 C# 軟體元件,允許 .NET 程式設計師從圖像和 PDF 文件中讀取 126 種語言(包括拉脫維亞語)的文字。
它是 Tesseract 的一個高級分支,專為 .NET 開發人員構建,在速度和準確性方面通常優於其他 Tesseract 引擎。
IronOcr.Languages.Latvian 的內容
此軟體包包含 46 種適用於 .NET 的 OCR 語言:
- 拉脫維亞語
- 拉脫維亞語最佳
- 拉脫維亞語Fast
下載
拉脫維亞語語言包[拉脫維亞語]
安裝
首先,你需要將拉脫維亞語OCR 套件安裝到你的 .NET 專案中。
程式碼範例
這段 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);
}
}
}Imports IronOcr
Module LatvianOCRExample
Sub Main()
' Create an instance of IronTesseract for OCR
Dim Ocr As New IronTesseract()
' Set the OCR language to Latvian
Ocr.Language = OcrLanguage.Latvian
' Define the input image file path
Using Input As 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 ModuleImports IronOcr
Module LatvianOCRExample
Sub Main()
' Create an instance of IronTesseract for OCR
Dim Ocr As New IronTesseract()
' Set the OCR language to Latvian
Ocr.Language = OcrLanguage.Latvian
' Define the input image file path
Using Input As 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 Module說明
- IronOCR命名空間: 範例開始時匯入
IronOcr命名空間,這對於存取OCR功能是必要的。 - IronTesseract實例: 創建
Ocr)來處理圖像讀取和文字擷取。 - 語言配置: OCR程序被配置為通過設定
Ocr.Language屬性來讀取拉脫維亞文。 - OcrInput物件: 創建一個
OcrInput物件,參考要處理的圖像文件。 - 讀取圖像: 在
Result變數。 - 結果擷取: 透過
AllText以供進一步使用或顯示。 - 主控台輸出: 拉脫維亞文識別文字被打印到主控台,提供文字擷取的視覺確認。
Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。