Używanie niestandardowych pakietów językowych OCR z IronOCR
Jak tworzyć niestandardowe pakiety językowe do użycia w IronOCR?
Tworzenie niestandardowego pakietu językowego wymaga treningu nowego pliku/słownika językowego LSTM Tesseract 4 z czcionki.
Dostępnych jest wiele samouczków online wyjaśniających kroki potrzebne do wykonania tego zadania. Proces nie jest prosty, ale na szczęście jest całkiem dobrze udokumentowany.
Jako dobre miejsce na początek sugerujemy ten samouczek YouTube od Gabriel Garcia (bez powiązań) oraz ich powiązane repozytorium GitHub.
Po zakończeniu, wynikiem będzie plik .traineddata.
Plik .traineddata można następnie zreferencjonować w IronOCR w następujący sposób:
Dokumentacja: 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

