9

I am trying to refine an OCR prog I made to read the layout of a certain image that I am using. Right now, I would like my OCR prog to recognise only digits 0-9.

I tried to follow the solution from the question:

Limit characters tesseract is looking for

But I got stuck in the part where I have to call tesseract as:

tesseract input.tif output nobatch letters  

where does this go?

4 Answers 4

8

i had the same issue using python, wit tesseract 3 Assuming further readers may do so.

from here : https://github.com/tesseract-ocr/tesseract/wiki/FAQ#how-do-i-recognize-only-digits

and here: https://github.com/madmaze/pytesseract/blob/27fed535bf1eb665ec991313841b177336b50f61/src/pytesseract.py#L91

i succeeded using :

pytesseract.image_to_string(someimage, config='outputbase digits')

6

I posted some things about tesseract some time ago in SO: see Tesseract OCR Library - Learning Font. There is notably a link to tesseract training which will tell you how to restrain your set of characters and describe your ambiguities.

4

This question is answered on Tesseract FAQ

And here is how you can get tesseract to recognise numbers only:

Tesseract 2 - BEFORE calling an Init function or put this in a text file called tessdata/configs/digits:

tessedit_char_whitelist 0123456789

and then your command line becomes:

tesseract image.tif outputbase nobatch digits

Tesseract 3 - A digits config file is already created, so just run a tesseract command like this:

tesseract imagename outputbase digits
1

It is the command you use to tesseract run on command line.

For a better answer, we need to know if you are running tesseract on command line or as a library.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.