henrivain / TesseractOcrMaui

Tesseract wrapper for Windows, Android and iOS for .NET MAUI
Apache License 2.0
37 stars 4 forks source link

Unable to detect single digit numbers #18

Closed adiamante closed 1 year ago

adiamante commented 1 year ago

Hi,

The following jpeg images are not able to be read:

1 2 3

The following does work so I'm guessing it's unable to read single digits.

524

I tested in windows TesseractOcrMauiTestApp project along with an android app. For android, I do know Xamarin.Tesseract package is able to read them properly but I am attempting to phase it out.

henrivain commented 1 year ago

Hi, Check if setting DefaultSegmentationMode property in TessEngine helps. Are you trying to only detect single digit numbers or do you have numbers that might be single digit in some cases?

using TessEngine engine = new("eng", "path/to/tessdatadir");
engine.DefaultSegmentationMode = PageSegmentationMode.SingleChar;

See PageSegmentationMode enum

Does the problem appear also with png images?

henrivain commented 1 year ago

I can find couple questions about the same problem

https://stackoverflow.com/questions/9632044/tesseract-does-not-recognize-single-characters

https://stackoverflow.com/questions/27581164/is-there-a-way-to-use-tesseract-for-single-digit-numbers

adiamante commented 1 year ago

@henrivain

PageSegmentationMode.SingleChar worked but PageSegmentationMode.SingleLine worked better for my use case.

Thanks