Icelandic 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#, pozwalający programistom .NET na odczytywanie tekstu z obrazów i dokumentów PDF w 126 językach, w tym po islandzku. Jest to zaawansowany fork Tesseract, zbudowany wyłącznie dla programistów .NET, i regularnie przewyższa inne silniki Tesseract zarówno pod względem szybkości, jak i dokładności.

Zawartość IronOcr.Languages.Icelandic

Pakiet ten zawiera 52 języki OCR dla .NET:

  • Islandzki
  • IslandzkiBest
  • IslandzkiFast

Pobieranie

Icelandic Language Pack [Íslenska]

Instalacja

Pierwszą rzeczą, którą musimy zrobić, jest zainstalowanie pakietu Islandzkiego OCR do projektu .NET.

Install-Package IronOcr.Languages.Icelandic

Przyklad kodu

Ten przykład kodu C# czyta tekst islandzki z obrazu lub dokumentu PDF.

using IronOcr;

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

        // Set the language to Icelandic
        Ocr.Language = OcrLanguage.Icelandic;

        // Load the image or PDF file to be processed
        using (var Input = new OcrInput(@"images\Icelandic.png"))
        {
            // Perform OCR on the input file
            var Result = Ocr.Read(Input);

            // Extract all recognized text from the result
            var AllText = Result.Text;

            // Print the extracted text to the console
            System.Console.WriteLine(AllText);
        }
    }
}
using IronOcr;

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

        // Set the language to Icelandic
        Ocr.Language = OcrLanguage.Icelandic;

        // Load the image or PDF file to be processed
        using (var Input = new OcrInput(@"images\Icelandic.png"))
        {
            // Perform OCR on the input file
            var Result = Ocr.Read(Input);

            // Extract all recognized text from the result
            var AllText = Result.Text;

            // Print the extracted text to the console
            System.Console.WriteLine(AllText);
        }
    }
}
Imports IronOcr

Friend Class Program
	Shared Sub Main()
		' Create an instance of the IronTesseract OCR engine
		Dim Ocr = New IronTesseract()

		' Set the language to Icelandic
		Ocr.Language = OcrLanguage.Icelandic

		' Load the image or PDF file to be processed
		Using Input = New OcrInput("images\Icelandic.png")
			' Perform OCR on the input file
			Dim Result = Ocr.Read(Input)

			' Extract all recognized text from the result
			Dim AllText = Result.Text

			' Print the extracted text to the console
			System.Console.WriteLine(AllText)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

Wyjaśnienie

  • Klasa IronTesseract jest częścią biblioteki IronOCR, zaprojektowanej do wykonywania operacji OCR.
  • Ocr.Language = OcrLanguage.Icelandic; ustawia język OCR na islandzki.
  • OcrInput przyjmuje ścieżkę do pliku wejściowego (obrazu lub PDF) i przygotowuje go do przetwarzania.
  • Ocr.Read(Input) przetwarza plik wejściowy i zwraca wynik OCR.
  • Result.Text pobiera cały rozpoznany tekst z przetworzonego pliku wejściowego.

Upewnij się, że masz zainstalowaną bibliotekę IronOCR i pakiet języka islandzkiego w swoim projekcie .NET, aby poprawnie uruchomić ten przykład.