Latvian OCR in C# and .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English
Outras versões deste documento:

IronOCR é um componente de software C# que permite aos programadores .NET ler texto de imagens e documentos PDF em 126 idiomas, incluindo o letão.

Trata-se de uma versão avançada do Tesseract, criada exclusivamente para desenvolvedores .NET e que supera regularmente outros mecanismos do Tesseract em termos de velocidade e precisão.

Conteúdo de IronOcr.Languages.Latvian

Este pacote contém 46 linguagens de OCR for .NET:

  • Letão
  • LetãoBest
  • LetãoFast

Baixar

Pacote de Idioma Letão [latviešu valoda]

Instalação

A primeira coisa que você precisa fazer é instalar o pacote OCR Latvian no seu projeto .NET.

Install-Package IronOcr.Languages.Latvian

Exemplo de código

Este exemplo de código C# lê texto letão de uma imagem ou documento 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

Explicação

  • Espaço de nomes IronOCR : O exemplo começa importando o espaço de nomes IronOcr, necessário para acessar as funcionalidades de OCR.
  • Instância IronTesseract: O objeto IronTesseract (Ocr) é criado para lidar com a leitura de imagens e a extração de texto.
  • Configuração de idioma: O processo de OCR está configurado para ler texto em letão definindo a propriedade Ocr.Language.
  • Objeto OcrInput: Um objeto OcrInput é criado, fazendo referência ao arquivo de imagem a ser processado.
  • Leitura da imagem: O método Read é chamado na instância Ocr para processar a imagem e extrair o texto, armazenado na variável Result.
  • Extração de resultados: Os resultados do OCR são acessados ​​através de Result.Text e armazenados em AllText para uso ou exibição posterior.
  • Saída no Console: O texto letão reconhecido é impresso no console, fornecendo uma confirmação visual da extração de texto.