Benutzerdefinierte OCR-Sprachpakete – Texterkennung erweitern mit IronOCR
Wie erstellt man benutzerdefinierte Sprachpakete zur Verwendung in IronOCR?
Das Erstellen eines benutzerdefinierten Sprachpakets erfordert das Training einer neuen Tesseract 4 LSTM Sprachdatei/Wörterbuch aus einer Schriftart.
Es gibt viele Tutorials online, die die erforderlichen Schritte dafür erklären. Der Prozess ist nicht einfach, aber zum Glück recht gut dokumentiert.
Als guter Ausgangspunkt empfehlen wir dieses YouTube-Tutorial von Gabriel Garcia (keine Verbindung) und deren verlinktes GitHub-Repository.
Nach Abschluss der Bearbeitung wird die Ausgabe eine .traineddata Datei sein.
Die Datei .traineddata kann dann in IronOCR wie folgt referenziert werden:
Dokumentation: IronOCR Custom Languages
using IronOcr;
class Program
{
static void Main()
{
// Initialize the IronTesseract OCR engine
var Ocr = new IronTesseract();
// Load your custom Tesseract language file (trained .traineddata file)
Ocr.UseCustomTesseractLanguageFile("mydir/custom.traineddata"); //<--- your new font
// Multiple fonts can be used by calling the method multiple times with different files
// Load an image into the OCR Input for processing
using (var Input = new OcrInput(@"images\image.png"))
{
// Perform OCR on the input image
var Result = Ocr.Read(Input);
// Output the recognized text to the console
Console.WriteLine(Result.Text);
}
}
}
using IronOcr;
class Program
{
static void Main()
{
// Initialize the IronTesseract OCR engine
var Ocr = new IronTesseract();
// Load your custom Tesseract language file (trained .traineddata file)
Ocr.UseCustomTesseractLanguageFile("mydir/custom.traineddata"); //<--- your new font
// Multiple fonts can be used by calling the method multiple times with different files
// Load an image into the OCR Input for processing
using (var Input = new OcrInput(@"images\image.png"))
{
// Perform OCR on the input image
var Result = Ocr.Read(Input);
// Output the recognized text to the console
Console.WriteLine(Result.Text);
}
}
}
Imports IronOcr
Friend Class Program
Shared Sub Main()
' Initialize the IronTesseract OCR engine
Dim Ocr = New IronTesseract()
' Load your custom Tesseract language file (trained .traineddata file)
Ocr.UseCustomTesseractLanguageFile("mydir/custom.traineddata") '<--- your new font
' Multiple fonts can be used by calling the method multiple times with different files
' Load an image into the OCR Input for processing
Using Input = New OcrInput("images\image.png")
' Perform OCR on the input image
Dim Result = Ocr.Read(Input)
' Output the recognized text to the console
Console.WriteLine(Result.Text)
End Using
End Sub
End Class

