Persian 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 odczytywać tekst z obrazów i dokumentów PDF w 126 językach, w tym po persku.

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.Persian

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

  • Perski
  • PersianBest
  • PersianFast

Pobieranie

Persian Language Pack [فارسی]

Instalacja

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

PM> Install-Package IronOcr.Languages.Persian

Przyklad kodu

Ten przykład kodu C# odczytuje tekst perski z obrazu lub dokumentu PDF.

// Install IronOcr.Languages.Persian package using NuGet Package Manager
// PM> Install-Package IronOcr.Languages.Persian

using IronOcr;

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

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

        // Load input image or PDF file
        using (var Input = new OcrInput(@"images\Persian.png"))
        {
            // Perform OCR to read text from the image
            var Result = Ocr.Read(Input);

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

            // Display the extracted text
            Console.WriteLine(AllText);
        }
    }
}
// Install IronOcr.Languages.Persian package using NuGet Package Manager
// PM> Install-Package IronOcr.Languages.Persian

using IronOcr;

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

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

        // Load input image or PDF file
        using (var Input = new OcrInput(@"images\Persian.png"))
        {
            // Perform OCR to read text from the image
            var Result = Ocr.Read(Input);

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

            // Display the extracted text
            Console.WriteLine(AllText);
        }
    }
}
' Install IronOcr.Languages.Persian package using NuGet Package Manager
' PM> Install-Package IronOcr.Languages.Persian

Imports IronOcr

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

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

		' Load input image or PDF file
		Using Input = New OcrInput("images\Persian.png")
			' Perform OCR to read text from the image
			Dim Result = Ocr.Read(Input)

			' Extract the recognized text
			Dim AllText = Result.Text

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

Powyższy przykład kodu demonstruje, jak używać biblioteki IronOCR do wykonania OCR na perskim obrazie. Ważne jest, aby zainstalowany był pakiet języka perskiego, a ścieżka do obrazu była poprawnie określona. Operacja OCR jest wykonywana w ramach instrukcji using, aby zapewnić właściwe zarządzanie zasobami.