Latin Alphabet OCR in C# and .NET
IronOCR é um componente de software C# que permite aos programadores .NET ler texto de imagens e documentos PDF em 126 idiomas, incluindo o Alfabeto Latino.
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údos de IronOcr.Languages.LatinAlphabet
Este pacote contém 64 idiomas de OCR for .NET:
- LatinAlphabet
- LatinAlphabetBest
- LatinAlphabetFast
Baixar
Pacote de Idioma do Alfabeto Latino [latine]
Instalação
A primeira coisa que temos que fazer é instalar nosso pacote OCR do Alfabeto Latino no seu projeto .NET.
Install-Package IronOcr.Languages.LatinAlphabet
Exemplo de código
Este exemplo de código C# lê texto em Alfabeto Latino de uma imagem ou documento PDF.
// Install the IronOCR.languages.LatinAlphabet package first
using IronOcr;
var Ocr = new IronTesseract(); // Initialize IronTesseract instance
// Set the OCR language to LatinAlphabet
Ocr.Language = OcrLanguage.LatinAlphabet;
// Define the input image or PDF you want to read
using (var Input = new OcrInput(@"images\LatinAlphabet.png"))
{
// Perform OCR reading on the input
var Result = Ocr.Read(Input);
// Extract the recognized text
var AllText = Result.Text;
// Output the recognized text
Console.WriteLine(AllText);
}
// Install the IronOCR.languages.LatinAlphabet package first
using IronOcr;
var Ocr = new IronTesseract(); // Initialize IronTesseract instance
// Set the OCR language to LatinAlphabet
Ocr.Language = OcrLanguage.LatinAlphabet;
// Define the input image or PDF you want to read
using (var Input = new OcrInput(@"images\LatinAlphabet.png"))
{
// Perform OCR reading on the input
var Result = Ocr.Read(Input);
// Extract the recognized text
var AllText = Result.Text;
// Output the recognized text
Console.WriteLine(AllText);
}
' Install the IronOCR.languages.LatinAlphabet package first
Imports IronOcr
Private Ocr = New IronTesseract() ' Initialize IronTesseract instance
' Set the OCR language to LatinAlphabet
Ocr.Language = OcrLanguage.LatinAlphabet
' Define the input image or PDF you want to read
Using Input = New OcrInput("images\LatinAlphabet.png")
' Perform OCR reading on the input
Dim Result = Ocr.Read(Input)
' Extract the recognized text
Dim AllText = Result.Text
' Output the recognized text
Console.WriteLine(AllText)
End Using
Explicação
-
Inicialização do IronTesseract: Uma instância de
IronTesseracté inicializada, que irá lidar com o processamento de OCR. -
Configuração de Idioma: O idioma do OCR é definido para
LatinAlphabet, que é um dos idiomas disponíveis no pacote IronOCR. -
Especificação de Entrada: Um objeto
OcrInputé criado, especificando o caminho para a imagem ou PDF do qual o texto será extraído. -
Execução de OCR: O método
Readda instânciaIronTesseracté chamado para processar oOcrInput. Isso retorna um objetoResultcontendo o texto extraído. -
Extração de Texto: A propriedade
Textdo objetoResulté usada para acessar o texto reconhecido. - Saída: O texto reconhecido é impresso no console para verificação.
Certifique-se de que o caminho do arquivo em OcrInput aponte corretamente para sua imagem ou arquivo PDF para evitar exceções de arquivo não encontrado.

