Uso de paquetes de idiomas de OCR personalizados con IronOCR
¿Cómo crear paquetes de idiomas personalizados para usar en IronOCR?
Crear un paquete de idioma personalizado requiere entrenar un nuevo archivo/diccionario de idioma LSTM de Tesseract 4 a partir de una fuente.
Hay muchos tutoriales disponibles en línea que explican los pasos necesarios para hacer esto. El proceso no es simple, pero afortunadamente está bastante bien documentado.
Como un buen punto de partida, sugerimos este tutorial de YouTube de Gabriel Garcia (sin afiliación) y su repositorio de GitHub relacionado.
Una vez completo, el resultado será un archivo .traineddata.
El archivo .traineddata puede luego referenciarse en IronOCR de la siguiente manera:
Documentación: 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





