Italian OCR in C# and .NET

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

IronOCR to komponent oprogramowania C#, który umożliwia programistom .NET odczytywanie tekstu z obrazów i dokumentów PDF w 126 językach, w tym po włosku.

Jest to zaawansowany fork Tesseracta, zbudowany wyłącznie dla deweloperów .NET i regularnie przewyższający inne silniki Tesseract pod względem szybkości i dokładności.

Zawartość IronOcr.Languages.Italian

Ten pakiet zawiera 6 trybów językowych OCR dla .NET:

  • Włoski
  • WloskiNajlepszy
  • WloskiSzybki
  • WloskiStary
  • WloskiStaryNajlepszy
  • WloskiStarySzybki

Pobieranie

Italian Language Pack [italiano]

Instalacja

Pierwszą rzeczą, którą musimy zrobić, jest zainstalowanie pakietu OCR Włoski do Twojego projektu .NET.

Install-Package IronOcr.Languages.Italian

Przyklad kodu

Ten przykład kodu C# odczytuje tekst włoski z obrazu lub dokumentu 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

Wyjaśnienie:

  1. Używanie IronOCR: Biblioteka IronOcr jest dołączona, aby wykorzystać jej możliwości OCR.
  2. Tworzenie instancji IronTesseract: IronTesseract jest klasą rdzeniową używaną do przetwarzania OCR.
  3. Ustawianie języka: OCR jest ustawiony, aby przetwarzać język włoski przy użyciu Ocr.Language = OcrLanguage.Italian.
  4. Odczytywanie wejścia: Obiekt OcrInput jest tworzony, aby określić plik obrazu.
  5. Wykonywanie OCR: Ocr.Read(Input) wykonuje proces OCR na obrazie wejściowym i zwraca wynik tekstowy.
  6. Wyjście: Otrzymany tekst jest zapisywany w AllText i wyświetlany w konsoli.

Upewnij się, że ścieżka do pliku images\Italian.png jest poprawna i że plik istnieje, aby przykład działał poprawnie.