DEV Community

IronSoftware
IronSoftware

Posted on • Originally published at ironsoftware.com

Tesseract Detailed Configuration

The IronTesseract.Configuration object provides access to the underlying Tesseract API in C# / .NET to configure setup for advanced users.

C#:

 var Ocr = new IronTesseract();

Ocr.Language = OcrLanguage.English;
Ocr.Configuration.ReadBarCodes = false;
Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
Ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm;
Ocr.Configuration.BlackListCharacters = "`ë|^";
Ocr.Configuration.RenderSearchablePdfsAndHocr = true;
Ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.AutoOsd;
Ocr.Configuration.TesseractVariables["tessedit_parallelize"] = false;

using (var Input = new OcrInput(@"images\image.png"))
{
    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}   
Enter fullscreen mode Exit fullscreen mode

VB:

Dim Ocr = New IronTesseract()

Ocr.Language = OcrLanguage.English
Ocr.Configuration.ReadBarCodes = False
Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5
Ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm
Ocr.Configuration.BlackListCharacters = "`ë|^"
Ocr.Configuration.RenderSearchablePdfsAndHocr = True
Ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.AutoOsd
Ocr.Configuration.TesseractVariables("tessedit_parallelize") = False

Using Input = New OcrInput("images\image.png")
    Dim Result = Ocr.Read(Input)
    Console.WriteLine(Result.Text)
End Using
Enter fullscreen mode Exit fullscreen mode

Top comments (0)