OCR italien en C# et .NET

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

IronOCR est un composant logiciel C# permettant aux développeurs .NET de lire du texte à partir d'images et de documents PDF dans 126 langues, dont l'italien.

Il s'agit d'une version avancée de Tesseract, conçue exclusivement pour les développeurs .NET et qui surpasse régulièrement les autres moteurs Tesseract en termes de vitesse et de précision.

Contenu de IronOcr.Languages.Italien

Ce package contient 6 modes de langue OCR pour .NET :

  • Italien
  • ItalianBest
  • ItalianFast
  • ItalianOld
  • ItalianOldBest
  • Vieux-déjeuner italien

Télécharger

Pack de langue italienne [italiano]

  • Télécharger au format ZIP
  • Installer avec NuGet

Installation

La première chose à faire est d'installer le package OCR italien sur votre projet .NET.

Install-Package IronOCR.Languages.Italian

Exemple de code

Cet exemple de code C# lit du texte italien à partir d'une image ou d'un document 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

Explication :

  1. Utilisation d'IronOCR : La bibliothèque IronOcr est incluse pour utiliser ses capacités OCR.
  2. Création d'une instance d'IronTesseract : IronTesseract est une classe de base utilisée pour le traitement OCR.
  3. Mise en place de la langue<\/strong> : l'OCR est configur\u00e9 pour traiter la langue italienne en utilisant Ocr.Language = OcrLanguage.Italian<\/code>.
  4. Lecture de l'entrée : Un objet OcrInput est créé pour spécifier le fichier image.
  5. Exécution de l'OCR : Ocr.Read(Input) exécute le processus OCR sur l'image d'entrée et renvoie le résultat textuel.
  6. Sortie : Le texte résultant est stocké dans AllText et affiché dans la console.

Pour que l'exemple fonctionne correctement, assurez-vous que le chemin d'accès au fichier images\Italian.png est correct et que le fichier existe.