Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make tesseract recognise numbers only

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?

like image 728
user1397215 Avatar asked Jul 03 '12 04:07

user1397215


4 Answers

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.

like image 56
Emmanuel Avatar answered Oct 22 '22 09:10

Emmanuel


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')

like image 36
cgte Avatar answered Oct 22 '22 08:10

cgte


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
like image 4
valentt Avatar answered Oct 22 '22 10:10

valentt


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.

like image 1
ojs Avatar answered Oct 22 '22 09:10

ojs