Wie man OCR-Sprachpakete in IronOCR verwendet

Additional OCR Language Packs

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

IronOCR unterstützt 125 internationale Sprachen, aber nur Englisch ist standardmäßig in IronOCR installiert.

Zusätzliche Sprachpakete können Ihrem C#-, VB- oder ASP .NET-Projekt einfach über NuGet oder als DLLs hinzugefügt werden, die heruntergeladen und als Projektverweise hinzugefügt werden können.

Beispiele für Code

Beispiel für internationale Sprache

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

Beispiel für vertikal geschriebene Sprache

Wörterbücher, die auf vertikal geschriebene Sprachen abgestimmt sind. Verwenden Sie die 'Vertikal'-Variante von Korean und Japanese OcrLanguage.

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

Beispiel für benutzerdefinierte Sprache

Zum Verwenden einer beliebigen Tesseract .traineddata-Sprachdatei, die Sie heruntergeladen oder selbst trainiert haben.

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

Beispiel für mehrere Sprachen

Mehr als eine Sprache gleichzeitig.

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

Beispiel für schnellere Sprache

Wörterbücher, die auf Geschwindigkeit abgestimmt sind. Verwenden Sie die 'Fast'-Variante einer beliebigen OcrLanguage.

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

Beispiel für höhere Genauigkeit im Detail

Wörterbücher, die auf Genauigkeit abgestimmt sind, jedoch mit deutlich langsameren Ergebnissen. Verwenden Sie die 'Best'-Variante einer beliebigen 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

Wie man OCR-Sprachpakete installiert

Zusätzliche OCR-Sprachpakete stehen unten zum Download bereit. Entweder

  • Installieren Sie das NuGet-Paket. Suche auf NuGet nach IronOcr-Sprachen.
  • Oder laden Sie die Datei "ocrdata" herunter und fügen Sie sie Ihrem .NET-Projekt in einem beliebigen Ordner hinzu. Setzen Sie CopyToOutputDirectory = CopyIfNewer

OCR-Sprachpakete herunterladen

class="languages__before-main-list">

.languagelist-item a, .languagelist-item span { display: block; width: fit-content; } .languagelist-item strong, .languagelist-item p { display: flex; gap: 10px; }

id="barcode-demo--thumbnail"> Barcode-Lesedemo öffnen

Hilfe

Wenn die von Ihnen gesuchte Sprache nicht in der obigen Liste verfügbar ist, bitte kontaktieren Sie uns. Viele andere Sprachen sind auf Anfrage erhältlich.

Priorität bei Produktionsressourcen wird Inhabern einer IronOCR-Lizenz gegeben, daher ziehen Sie bitte auch in Betracht, eine Lizenz für IronOCR zu erwerben, um Zugriff auf Ihr gewünschtes Sprachpaket zu erhalten.