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.Languages.Latvian 的内容

此软件包包含 46 种适用于 .NET 的 OCR 语言:

  • 拉脱维亚语
  • 拉脱维亚语最佳
  • 拉脱维亚语Fast

下载

拉脱维亚语语言包[拉脱维亚语]

安装

首先,你需要将拉脱维亚语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 实例: 创建Ocr),用于处理图像读取和文本提取。
  • 语言配置: OCR过程通过设置Ocr.Language属性来配置读取拉脱维亚文本。
  • OcrInput 对象: 创建OcrInput对象,引用要处理的图像文件。
  • 读取图像:Result变量中。
  • 结果提取: 通过AllText中以供进一步使用或显示。 -控制台输出:识别出的拉脱维亚语文本会打印到控制台上,从而提供文本提取的视觉确认。