Sinhala 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 w sinhala.

Jest to zaawansowany fork Tesseract, zbudowany wyłącznie dla deweloperów .NET, który regularnie przewyższa inne silniki Tesseract zarówno pod względem szybkości, jak i dokładności.

Zawartość IronOcr.Languages.Sinhala

Ten pakiet zawiera 114 języków OCR dla .NET:

  • Sinhala
  • SinhalaBest
  • SinhalaFast
  • SinhalaAlfabet
  • SinhalaAlfabetBest
  • SinhalaAlfabetFast

Pobieranie

Sinhala Language Pack [සංහල]

Instalacja

Pierwszą rzeczą, którą musimy zrobić, jest zainstalowanie pakietu OCR Sinhala w Twoim projekcie .NET.

Install-Package IronOcr.Languages.Sinhala

Przyklad kodu

Ten przykład kodu C# odczytuje tekst w języku sinhala z obrazu lub dokumentu PDF.

// Import the IronOcr namespace
using IronOcr;

class SinhalaOcrExample
{
    static void Main()
    {
        // Initialize the IronTesseract OCR engine
        var Ocr = new IronTesseract();

        // Set the OCR engine to use the Sinhala language
        Ocr.Language = OcrLanguage.Sinhala;

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

            // Retrieve the recognized text
            var AllText = Result.Text;

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

class SinhalaOcrExample
{
    static void Main()
    {
        // Initialize the IronTesseract OCR engine
        var Ocr = new IronTesseract();

        // Set the OCR engine to use the Sinhala language
        Ocr.Language = OcrLanguage.Sinhala;

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

            // Retrieve the recognized text
            var AllText = Result.Text;

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

Friend Class SinhalaOcrExample
	Shared Sub Main()
		' Initialize the IronTesseract OCR engine
		Dim Ocr = New IronTesseract()

		' Set the OCR engine to use the Sinhala language
		Ocr.Language = OcrLanguage.Sinhala

		' Define the input image or PDF file
		Using Input = New OcrInput("images\Sinhala.png")
			' Perform OCR on the input
			Dim Result = Ocr.Read(Input)

			' Retrieve the recognized text
			Dim AllText = Result.Text

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

Wyjaśnienie:

  • IronTesseract: Jest to główna klasa silnika OCR używana do rozpoznawania tekstu.
  • Language: Określa język tekstu, który ma zostać rozpoznany; w tym przypadku sinhala.
  • OcrInput: Reprezentuje plik wejściowy (obraz lub PDF), w którym trzeba przeprowadzić rozpoznawanie tekstu.
  • Read: Wykonuje proces OCR na pliku wejściowym i zwraca rozpoznany tekst.
  • Result.Text: Zawiera tekst rozpoznany przez OCR z pliku wejściowego, który można wykorzystać do dalszego przetwarzania lub wyświetlania.