Latin Alphabet OCR in C# and .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English

126 autres langues

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, y compris l'alphabet latin.

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

Ce package contient 64 langues OCR for .NET :

  • Alphabet latin
  • Alphabet latinBest
  • Alphabet latin rapide

Télécharger

Pack de langue alphabet latin [latin]

  • Télécharger en tant que Zip
  • Installer avec NuGet

Installation

La première chose à faire est d'installer notre package OCR d'alphabet latin sur votre projet .NET.

Install-Package IronOcr.Languages.LatinAlphabet

Exemple de code

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

// Install the IronOCR.languages.LatinAlphabet package first
using IronOcr;

var Ocr = new IronTesseract(); // Initialize IronTesseract instance

// Set the OCR language to LatinAlphabet
Ocr.Language = OcrLanguage.LatinAlphabet;

// Define the input image or PDF you want to read
using (var Input = new OcrInput(@"images\LatinAlphabet.png"))
{
    // Perform OCR reading on the input
    var Result = Ocr.Read(Input);

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

    // Output the recognized text
    Console.WriteLine(AllText);
}
// Install the IronOCR.languages.LatinAlphabet package first
using IronOcr;

var Ocr = new IronTesseract(); // Initialize IronTesseract instance

// Set the OCR language to LatinAlphabet
Ocr.Language = OcrLanguage.LatinAlphabet;

// Define the input image or PDF you want to read
using (var Input = new OcrInput(@"images\LatinAlphabet.png"))
{
    // Perform OCR reading on the input
    var Result = Ocr.Read(Input);

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

    // Output the recognized text
    Console.WriteLine(AllText);
}
' Install the IronOCR.languages.LatinAlphabet package first
Imports IronOcr

Private Ocr = New IronTesseract() ' Initialize IronTesseract instance

' Set the OCR language to LatinAlphabet
Ocr.Language = OcrLanguage.LatinAlphabet

' Define the input image or PDF you want to read
Using Input = New OcrInput("images\LatinAlphabet.png")
	' Perform OCR reading on the input
	Dim Result = Ocr.Read(Input)

	' Extract the recognized text
	Dim AllText = Result.Text

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

Explication

  1. Initialisation de IronTesseract : Une instance de IronTesseract est initialisée, laquelle gérera le traitement OCR.

  2. Paramètre de langue : La langue OCR est définie sur LatinAlphabet, qui est l'une des langues disponibles dans le package IronOCR.

  3. Spécification de l'entrée : Un objet OcrInput est créé, spécifiant le chemin vers l'image ou le PDF à partir duquel le texte sera extrait.

  4. Exécution de l'OCR : La méthode Read de l'instance IronTesseract est appelée pour traiter le OcrInput. Cela retourne un objet Result contenant le texte extrait.

  5. Extraction du texte : La propriété Text de l'objet Result est utilisée pour accéder au texte reconnu.

  6. Sortie : Le texte reconnu est imprimé sur la console pour vérification.

Assurez-vous que le chemin de fichier dans OcrInput pointe correctement vers votre fichier image ou PDF pour éviter les exceptions de fichier introuvable.