Welsh 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 jest komponentem oprogramowania C#, który umożliwia programistom .NET odczytywanie tekstu z obrazów i dokumentów PDF w 126 językach, w tym w języku walijskim. Jest to zaawansowany fork Tesseract, stworzony 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.Welsh

Ten pakiet zawiera trzy wersje języka OCR walijskiego dla .NET:

  • Welsh
  • WelshBest
  • WelshFast

Pobieranie

Welsh Language Pack [Cymraeg]

Instalacja

Pierwszym krokiem jest zainstalowanie pakietu Welsh OCR w swoim projekcie .NET.

Install-Package IronOcr.Languages.Welsh

Przyklad kodu

Ten przykład kodu C# demonstruje, jak odczytać tekst w języku walijskim z obrazu lub dokumentu PDF.

// Import the IronOcr namespace
using IronOcr;

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

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

        // Read text from the given image
        using (var Input = new OcrInput(@"images\Welsh.png"))
        {
            // Perform OCR and get the result
            var Result = Ocr.Read(Input);

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

            // Output text to the console
            Console.WriteLine(AllText);
        }
    }
}
// Import the IronOcr namespace
using IronOcr;

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

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

        // Read text from the given image
        using (var Input = new OcrInput(@"images\Welsh.png"))
        {
            // Perform OCR and get the result
            var Result = Ocr.Read(Input);

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

            // Output text to the console
            Console.WriteLine(AllText);
        }
    }
}
' Import the IronOcr namespace
Imports IronOcr

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

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

		' Read text from the given image
		Using Input = New OcrInput("images\Welsh.png")
			' Perform OCR and get the result
			Dim Result = Ocr.Read(Input)

			' Extract all recognized text
			Dim AllText = Result.Text

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

W tym kodzie:

  • Zaczynamy od użycia przestrzeni nazw IronOcr, aby uzyskać dostęp do funkcji OCR.
  • Tworzymy instancję IronTesseract, która jest główną klasą dostarczaną przez IronOCR do wykonywania operacji OCR.
  • Język OCR jest ustawiony na walijski przy użyciu Ocr.Language = OcrLanguage.Welsh.
  • Otwieramy plik obrazu o nazwie Welsh.png znajdujący się w katalogu images do przetwarzania OCR.
  • Na koniec metoda Ocr.Read(Input) odczytuje tekst z obrazu, a wyodrębniony tekst jest przechowywany w AllText.
  • Rozpoznany tekst w języku walijskim jest następnie drukowany na konsolę.