Latvian OCR in C# and .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English
本文檔的其他版本:

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

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

IronOCR的內容.語言.拉脫維亞語

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

  • 拉脫維亞語
  • LatvianBest
  • LatvianFast

下載

拉脫維亞語語言包[latviešu valoda]

安裝

首先,你需要將拉脫維亞語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);
        }
    }
}
$vbLabelText   $csharpLabel

解釋

  • IronOCR命名空間:範例首先匯入 IronOcr 命名空間,這是存取 OCR 功能所必需的。
  • IronTesseract 實例:建立 IronTesseract 物件 (Ocr) 來處理影像讀取和文字擷取。 -語言配置:透過設定 Ocr.Language 屬性,將 OCR 流程配置為讀取拉脫維亞文本。
  • OcrInput 物件:建立一個 OcrInput 對象,引用要處理的影像檔案。 -讀取圖像:Read 實例呼叫 Ocr 方法來處理圖像並提取文本,儲存在 Result 變數中。 -結果提取: OCR 結果透過 Result.Text 訪問,並儲存在 AllText 中以供進一步使用或顯示。 -控制台輸出:辨識出的拉脫維亞文字會印到控制台上,從而提供文字擷取的視覺確認。