OCR serbe en C# et .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English
Other versions of this document:

IronOCR est un composant logiciel C# permettant aux développeurs .NET de lire du texte à partir d'images et de documents PDF dans 126 langues, dont le serbe. Il s'agit d'une version avancée de Tesseract, conçue exclusivement pour les développeurs .NET et qui surpasse régulièrement les autres moteurs Tesseract en termes de vitesse et de précision.

Contenu de IronOcr.Languages.Serbe

Ce package contient 105 langues OCR pour .NET :

  • Serbe
  • SerbeBest
  • SerbeFast
  • Serbe-Latin
  • Serbe-LatinBest
  • Serbe-LatinFast

Télécharger

Pack de langue serbe [српски језик]

Installation

La première chose que nous devons faire est d'installer notre paquet OCR Serbe dans votre projet .NET.

Install-Package IronOcr.Languages.Serbian

Exemple de code

Cet exemple de code C# lit du texte serbe à partir d'une image ou d'un document PDF.

// Ensure all necessary namespaces are imported
using IronOcr;

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

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

        // Use a using statement to ensure resources are disposed properly
        using (var Input = new OcrInput(@"images\Serbian.png"))
        {
            // Perform OCR and store the result
            var Result = Ocr.Read(Input);

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

            // Output the resulting text
            Console.WriteLine(AllText);
        }
    }
}
// Ensure all necessary namespaces are imported
using IronOcr;

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

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

        // Use a using statement to ensure resources are disposed properly
        using (var Input = new OcrInput(@"images\Serbian.png"))
        {
            // Perform OCR and store the result
            var Result = Ocr.Read(Input);

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

            // Output the resulting text
            Console.WriteLine(AllText);
        }
    }
}
' Ensure all necessary namespaces are imported
Imports IronOcr

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

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

		' Use a using statement to ensure resources are disposed properly
		Using Input = New OcrInput("images\Serbian.png")
			' Perform OCR and store the result
			Dim Result = Ocr.Read(Input)

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

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

Explication du code :

  • Nous initialisons une nouvelle instance d' IronTesseract qui est utilisée pour effectuer la reconnaissance optique de caractères (OCR).
  • La langue du moteur OCR est définie sur le serbe à l'aide de OcrLanguage.Serbian .
  • Nous chargeons l'image Serbian.png à l'aide OcrInput qui lit le fichier à partir du chemin spécifié.
  • La fonction Read est appelée sur l'objet OCR pour traiter l'image et extraire le texte.
  • Le texte extrait de l'image est stocké dans la variable AllText puis affiché dans la console.