Tesseract Trained data

nicky picture nicky · Aug 26, 2012 · Viewed 23.3k times · Source

Am trying to extract data from reciepts and bills using Tessaract , am using tesseract 3.02 version .

am using only english data , Still the output accuracy is about 60%.

Is there any trained data available which i just replace in tessdata folder

Answer

Kurt Pfeifle picture Kurt Pfeifle · Aug 29, 2012

This is the image nicky provided as a "typical example file":

typical example file

Looking at it I'd clearly say: "Forget it, nicky! You cannot train Tesseract to recognize 100% of text from this type of image!"

However, you could train yourself to make better photos with your iPhone 3GS (that's the device which was used for the example pictures) from such type of receipts. Here are a few tips:

  • Don't use a dark background. Use white instead.
  • Don't let the receipt paper crumble. Straighten it out.
  • Don't place the receipt loosely on an uneven underground. Fix it to a flat surface:
    • Either place it on a white sheet of paper and put a glas platen over it.
    • Or use some glue and glue it flat on a white sheet of paper without any bend-up edges or corners.
  • Don't use a low resolution like just 640x480 pixels (as the example picture has). Use a higher one, such as 1280x960 pixels instead.
  • Don't use standard exposure. Set the camera to use extremely high contrast. You want the letters to be black and the white background to be really white (you don't need the grays in the picture...)
  • Try to make it so that any character of a 10-12 pt font uses about 24-30 pixels in height (that is, make the image to be about 300 dpi for 100% zoom).

That said, something like the following ImageMagick command will probably increase Tesseract's recognition rate by some degree:

convert                               \
   http://i.stack.imgur.com/q3Ad4.jpg \
  -colorspace gray                    \
  -rotate 90                          \
  -crop 260x540+110+75 +repage        \
  -scale 166%                         \
  -normalize                          \
  -colors 32                          \
   out1 .png

It produces the following output:

ImageMagick optimization for OCR

You could even add something like -threshold 30% as the last commandline option to above command to get this:

enter image description here

(You should play a bit with some variations to the 30% value to tweak the result... I don't have the time for this.)