OCR del alfabeto latino en C# y .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English

126 idiomas más

IronOCR es un componente de software C# que permite a los programadores de .NET leer texto de imágenes y documentos PDF en 126 idiomas, incluido el alfabeto latino.

Es una rama avanzada de Tesseract, construida exclusivamente para desarrolladores de .NET y supera regularmente a otros motores de Tesseract tanto en velocidad como en precisión.

Contenido de IronOcr.Languages.LatinAlphabet

Este paquete contiene 64 idiomas OCR para .NET:

  • LatinAlphabet
  • LatinAlphabetBest
  • LatinAlphabetFast

Descargar

Paquete de idioma del alfabeto latino [latine]

Instalación

Lo primero que tenemos que hacer es instalar nuestro paquete OCR del alfabeto latino en su proyecto .NET.

Install-Package IronOCR.Languages.LatinAlphabet

Ejemplo de código

Este ejemplo de código C# lee texto del alfabeto latino de una imagen o 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
$vbLabelText   $csharpLabel

Explicación

  1. Inicialización de IronTesseract: Se inicializa una instancia de IronTesseract, que manejará el procesamiento de OCR.

  2. Configuración del idioma: El idioma OCR se establece en LatinAlphabet, que es uno de los idiomas disponibles en el paquete IronOCR.

  3. Especificación de entrada: Se crea un objeto OcrInput, especificando la ruta a la imagen o PDF de la que se extraerá el texto.

  4. Ejecución de OCR: Se llama al método Read de la instancia de IronTesseract para procesar el OcrInput. Esto devuelve un objeto Result que contiene el texto extraído.

  5. Extracción de texto: Se utiliza la propiedad Text del objeto Result para acceder al texto reconocido.

  6. Salida: El texto reconocido se imprime en la consola para verificación.

Asegúrese de que la ruta del archivo en OcrInput apunte correctamente a su archivo de imagen o PDF para evitar excepciones de archivo no encontrado.