IronOCR でカスタム OCR 言語パックを使用する
IronOCR で使用するためのカスタム言語パックを作成するにはどうすればよいですか?
カスタム言語パックを作成するには、フォントから新しい Tesseract 4 LSTM 言語ファイル/辞書をトレーニングする必要があります。
これを行うために必要な手順を説明するチュートリアルがオンラインで多数提供されています。 このプロセスは簡単ではありませんが、ありがたいことに非常によく文書化されています。
始めるのに適した場所として、 Gabriel Garcia (提携関係なし) によるこのYouTube チュートリアルと、それにリンクされているGitHub リポジトリをお勧めします。
完了すると、出力は.traineddataファイルになります。
.traineddataファイルは、次のように IronOCR で参照できます。
ドキュメント: IronOCR カスタム言語
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





