Italian OCR in C# and .NET

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

IronOCR ist eine C#-Softwarekomponente, die es .NET-Entwicklern ermöglicht, Text aus Bildern und PDF-Dokumenten in 126 Sprachen zu lesen, einschließlich Italienisch.

Es ist eine erweiterte Abspaltung von Tesseract, die exklusiv for .NET-Entwickler entwickelt wurde und regelmäßig andere Tesseract-Engines sowohl in Bezug auf Geschwindigkeit als auch Genauigkeit übertrifft.

Inhalt von IronOcr.Languages.Italian

Dieses Paket enthält 6 OCR-Sprachmodi for .NET:

  • Italienisch
  • ItalienischBest
  • ItalienischFast
  • ItalienischAlt
  • ItalienischAltBest
  • ItalienischOldFast

Download

Italienisches Sprachpaket [italiano]

Installation

Das erste, was wir tun müssen, ist das Italienisch-OCR-Paket in Ihrem .NET-Projekt zu installieren.

Install-Package IronOcr.Languages.Italian

Beispielcode

Dieses C#-Code-Beispiel liest italienischen Text aus einem Bild oder PDF-Dokument.

// 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

Erklärung:

  1. Verwendung von IronOCR: Die IronOCR-Bibliothek IronOcr ist enthalten, um deren OCR-Funktionen zu nutzen.
  2. Erstellen einer IronTesseract-Instanz: IronTesseract ist eine Kernklasse, die für die OCR-Verarbeitung verwendet wird.
  3. Spracheinstellung: OCR ist so eingestellt, dass die italienische Sprache mit Ocr.Language = OcrLanguage.Italian verarbeitet wird.
  4. Eingabe lesen: Es wird ein OcrInput-Objekt erstellt, um die Bilddatei anzugeben.
  5. OCR durchführen: Ocr.Read(Input) führt den OCR-Prozess auf dem Eingabebild aus und gibt das Textergebnis zurück.
  6. Ausgabe: Der resultierende Text wird in AllText gespeichert und in der Konsole angezeigt.

Stellen Sie sicher, dass der Dateipfad images\Italian.png korrekt ist und die Datei vorhanden ist, damit das Beispiel ordnungsgemäß funktioniert.