2

I'm working on an image classification task, and I am using Tesseract OCR for digit classification.

My main problem is receiving really poor results from the OCR for single digits.

After reading a lot online about improving Tesseract's performance, I am pre-processing the image with OpenCV using the following general scheme:

  1. finding contours
  2. bounding boxes
  3. cropping to the boxes to get single digits
  4. thresholding to get binary image
  5. padding the image by adding white background
  6. blurring.

I am getting something I'm fairly pleased with, for example:

I am calling Tesseract in the following way, emphasizing that I am expecting a single digit:

tesseract input.jpg output.txt - psm 10 digits

I thought Tesseract would surely identify it correctly, but it returns ".".

Does anyone have ideas for further improvements? I'm guessing I could train Tesseract for this specific font, but since I would be dealing with different fonts I'm hoping for a better approach.

Miki
  • 40,887
  • 13
  • 123
  • 202
galoosh33
  • 326
  • 3
  • 14
  • 1
    See my answer in http://stackoverflow.com/questions/34176517/ocr-not-getting-desired-result/34180452#34180452 . Using https://www.newocr.com/ on your image fails, but works if multiple concatenations of your image are given (I tried with "66666666" and it worked). – Micka Feb 01 '16 at 15:27
  • Thanks for the tip. What I ended up doing, in light of what you said, was to put the single characters back into one image and then sending that image to the OCR, and for some reason it performed much better. – galoosh33 Feb 07 '16 at 13:34

2 Answers2

1

What version of Tesseract? It works for me (note: there should not be a space between '-' and 'psm').

$ tesseract ~/Downloads/6digit.jpg stdout -psm 10 digits
6

$ tesseract -v
tesseract 3.05.00dev
 leptonica-1.71
  libgif 4.2.3 : libjpeg 9a : libpng 1.6.21 : libtiff 4.0.6 : zlib 1.2.8 : libwebp 0.5.0 : libopenjp2 2.1.0
Tom Morris
  • 10,490
  • 32
  • 53
0

What I ended up doing, in light of what @micka commented, was to assemble all the single characters back into one image and then send that image to the OCR. For some reason which is still unclear to me, it really improves the results.

galoosh33
  • 326
  • 3
  • 14