Comment utiliser les packs de langues OCR dans IronOCR

Packs de langues OCR supplémentaires

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

IronOCR prend en charge 125 langues internationales, mais seul l'anglais est installé par défaut dans IronOCR.

Des modules linguistiques supplémentaires peuvent être facilement ajoutés à votre projet C#, VB ou ASP.NET via NuGet ou sous forme de DLL téléchargeables et ajoutables comme références de projet.

Exemples de code

Exemple de langue internationale

Install-Package IronOcr.Languages.ChineseSimplified
using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use Chinese Simplified
ocr.Language = OcrLanguage.ChineseSimplified;

using (var input = new OcrInput())
{
    // Add an image to be processed
    input.AddImage("img/chinese.gif");

    // Optional: Enhance the input by deskewing or denoising the image
    // input.Deskew();
    // input.DeNoise();

    // Process the image and retrieve the result
    var result = ocr.Read(input);

    // Store the recognized text in a string
    string testResult = result.Text;

    // Save the recognized text to a file since the console might not display Unicode characters properly
    result.SaveAsTextFile("chinese.txt");
}
using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use Chinese Simplified
ocr.Language = OcrLanguage.ChineseSimplified;

using (var input = new OcrInput())
{
    // Add an image to be processed
    input.AddImage("img/chinese.gif");

    // Optional: Enhance the input by deskewing or denoising the image
    // input.Deskew();
    // input.DeNoise();

    // Process the image and retrieve the result
    var result = ocr.Read(input);

    // Store the recognized text in a string
    string testResult = result.Text;

    // Save the recognized text to a file since the console might not display Unicode characters properly
    result.SaveAsTextFile("chinese.txt");
}
Imports IronOcr

Private ocr = New IronTesseract()
' Set the OCR to use Chinese Simplified
ocr.Language = OcrLanguage.ChineseSimplified

Using input = New OcrInput()
	' Add an image to be processed
	input.AddImage("img/chinese.gif")

	' Optional: Enhance the input by deskewing or denoising the image
	' input.Deskew();
	' input.DeNoise();

	' Process the image and retrieve the result
	Dim result = ocr.Read(input)

	' Store the recognized text in a string
	Dim testResult As String = result.Text

	' Save the recognized text to a file since the console might not display Unicode characters properly
	result.SaveAsTextFile("chinese.txt")
End Using
$vbLabelText   $csharpLabel

Exemple de langue écrite verticalement

Dictionnaires adaptés aux langues à écriture verticale. Utilisez la variante " verticale " des langues OCR coréenne et japonaise.

using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use Japanese Vertical language
ocr.Language = OcrLanguage.JapaneseVertical;

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use Japanese Vertical language
ocr.Language = OcrLanguage.JapaneseVertical;

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
Imports IronOcr

Private ocr = New IronTesseract()
' Set the OCR to use Japanese Vertical language
ocr.Language = OcrLanguage.JapaneseVertical

Using input = New OcrInput("images\image.png")
	' Process the image and get the OCR result
	Dim result = ocr.Read(input)
	' Output the recognized text to the console
	Console.WriteLine(result.Text)
End Using
$vbLabelText   $csharpLabel

Exemple de langue personnalisée

Pour utiliser n'importe quel fichier de langue Tesseract .traineddata que vous avez téléchargé ou entraîné vous-même.

using IronOcr;

var ocr = new IronTesseract();

// Use a custom Tesseract language file
ocr.UseCustomTesseractLanguageFile("custom_tesseract_files/custom.traineddata");

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
using IronOcr;

var ocr = new IronTesseract();

// Use a custom Tesseract language file
ocr.UseCustomTesseractLanguageFile("custom_tesseract_files/custom.traineddata");

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
Imports IronOcr

Private ocr = New IronTesseract()

' Use a custom Tesseract language file
ocr.UseCustomTesseractLanguageFile("custom_tesseract_files/custom.traineddata")

Using input = New OcrInput("images\image.png")
	' Process the image and get the OCR result
	Dim result = ocr.Read(input)
	' Output the recognized text to the console
	Console.WriteLine(result.Text)
End Using
$vbLabelText   $csharpLabel

Exemple multilingue

Plusieurs langues à la fois.

Install-Package IronOcr.Languages.Arabic
using IronOcr;

var ocr = new IronTesseract();

// Set the primary language to English
ocr.Language = OcrLanguage.English;
// Add Arabic as a secondary language
ocr.AddSecondaryLanguage(OcrLanguage.Arabic);
// Add any number of languages

using (var input = new OcrInput(@"images\multi-lang.pdf"))
{
    // Process the PDF and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
using IronOcr;

var ocr = new IronTesseract();

// Set the primary language to English
ocr.Language = OcrLanguage.English;
// Add Arabic as a secondary language
ocr.AddSecondaryLanguage(OcrLanguage.Arabic);
// Add any number of languages

using (var input = new OcrInput(@"images\multi-lang.pdf"))
{
    // Process the PDF and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
Imports IronOcr

Private ocr = New IronTesseract()

' Set the primary language to English
ocr.Language = OcrLanguage.English
' Add Arabic as a secondary language
ocr.AddSecondaryLanguage(OcrLanguage.Arabic)
' Add any number of languages

Using input = New OcrInput("images\multi-lang.pdf")
	' Process the PDF and get the OCR result
	Dim result = ocr.Read(input)
	' Output the recognized text to the console
	Console.WriteLine(result.Text)
End Using
$vbLabelText   $csharpLabel

Exemple de langage plus rapide

Dictionnaires optimisés pour la rapidité. Utilisez la variante " Rapide " de n'importe quel langage Ocr.

using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use the fast variant of English
ocr.Language = OcrLanguage.EnglishFast;

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use the fast variant of English
ocr.Language = OcrLanguage.EnglishFast;

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
Imports IronOcr

Private ocr = New IronTesseract()
' Set the OCR to use the fast variant of English
ocr.Language = OcrLanguage.EnglishFast

Using input = New OcrInput("images\image.png")
	' Process the image and get the OCR result
	Dim result = ocr.Read(input)
	' Output the recognized text to the console
	Console.WriteLine(result.Text)
End Using
$vbLabelText   $csharpLabel

Exemple de langage détaillé de haute précision

Des dictionnaires optimisés pour la précision, mais avec des résultats beaucoup plus lents. Utilisez la meilleure variante de chaque langue OcrLanguage.

Install-Package IronOcr.Languages.French
using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use the best variant of French
ocr.Language = OcrLanguage.FrenchBest;

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
using IronOcr;

var ocr = new IronTesseract();
// Set the OCR to use the best variant of French
ocr.Language = OcrLanguage.FrenchBest;

using (var input = new OcrInput(@"images\image.png"))
{
    // Process the image and get the OCR result
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);
}
Imports IronOcr

Private ocr = New IronTesseract()
' Set the OCR to use the best variant of French
ocr.Language = OcrLanguage.FrenchBest

Using input = New OcrInput("images\image.png")
	' Process the image and get the OCR result
	Dim result = ocr.Read(input)
	' Output the recognized text to the console
	Console.WriteLine(result.Text)
End Using
$vbLabelText   $csharpLabel

Comment installer les packs de langue OCR

Des packs de langues OCR supplémentaires sont disponibles en téléchargement ci-dessous. Soit

  • Installez le package NuGet. Rechercher les langages IronOCR sur NuGet . Vous pouvez également télécharger le fichier " ocrdata " et l'ajouter à votre projet .NET dans le dossier de votre choix. Définissez CopyToOutputDirectory = CopyIfNewer

Télécharger les packs de langues OCR

Aide

Si la langue que vous souhaitez lire ne figure pas dans la liste ci-dessus, veuillez nous contacter . De nombreuses autres langues sont disponibles sur demande.

La priorité sur les ressources de production est accordée aux titulaires de licence IronOCR, alors veuillez également envisager la licence d'IronOCR pour l'accès à votre pack de langue désiré.