OCR italiano en C# y .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English
Other versions of this document:

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 italiano.

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.Italian

Este paquete contiene 6 modos de idioma OCR para .NET:

  • Italiano
  • ItalianoMejor
  • ItalianoRápido
  • ItalianoAntiguo
  • ItalianoAntiguoMejor
  • ItalianoAntiguoRápido

Descargar

Paquete de idioma italiano [italiano]

Instalación

Lo primero que tenemos que hacer es instalar el paquete OCR Italiano en tu proyecto .NET.

Install-Package IronOCR.Languages.Italian

Ejemplo de código

Este ejemplo de código C# lee texto en italiano de una imagen o documento PDF.

// Include IronOcr library
using IronOcr;

class Program
{
    static void Main()
    {
        // Create a new instance of the IronTesseract class
        var Ocr = new IronTesseract();

        // Set the OCR language to Italian
        Ocr.Language = OcrLanguage.Italian;

        // Read text from an image file
        using (var Input = new OcrInput(@"images\Italian.png"))
        {
            // Perform OCR to get the text content from the image
            var Result = Ocr.Read(Input);

            // Get and print all the recognized text
            var AllText = Result.Text;
            Console.WriteLine(AllText);
        }
    }
}
// Include IronOcr library
using IronOcr;

class Program
{
    static void Main()
    {
        // Create a new instance of the IronTesseract class
        var Ocr = new IronTesseract();

        // Set the OCR language to Italian
        Ocr.Language = OcrLanguage.Italian;

        // Read text from an image file
        using (var Input = new OcrInput(@"images\Italian.png"))
        {
            // Perform OCR to get the text content from the image
            var Result = Ocr.Read(Input);

            // Get and print all the recognized text
            var AllText = Result.Text;
            Console.WriteLine(AllText);
        }
    }
}
' Include IronOcr library
Imports IronOcr

Friend Class Program
	Shared Sub Main()
		' Create a new instance of the IronTesseract class
		Dim Ocr = New IronTesseract()

		' Set the OCR language to Italian
		Ocr.Language = OcrLanguage.Italian

		' Read text from an image file
		Using Input = New OcrInput("images\Italian.png")
			' Perform OCR to get the text content from the image
			Dim Result = Ocr.Read(Input)

			' Get and print all the recognized text
			Dim AllText = Result.Text
			Console.WriteLine(AllText)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

Explicación:

  1. Usando IronOCR: La biblioteca IronOcr se incluye para utilizar sus capacidades de OCR.
  2. Creando una instancia de IronTesseract: IronTesseract es una clase principal utilizada para el procesamiento de OCR.
  3. Estableciendo el idioma: El OCR está configurado para procesar el idioma italiano usando Ocr.Language = OcrLanguage.Italian.
  4. Lectura de entrada: Se crea un objeto OcrInput para especificar el archivo de imagen.
  5. Realización de OCR: Ocr.Read(Input) ejecuta el proceso de OCR en la imagen de entrada y devuelve el texto resultante.
  6. Salida: El texto resultante se almacena en AllText y se muestra en la consola.

Asegúrate de que la ruta del archivo images\Italian.png sea correcta y que el archivo exista para que el ejemplo funcione correctamente.