8

I was hoping someone could tell me why it is my Tesseract has trouble recognizing some images with digits, and if there is something i can do about it. Everything is working according to test, and since it is only digits i need, i thought i could manage with the english pattern untill i had to start with the 7segmented display aswell.

Though i am having a lot of trouble with the appended images, i'd like to know if i should start working on my own recognition algorithms or if I could do my own datasets for Tesseract and then it would work, does anyone know where the limitation lies with Tesseract?

things tried: tried to set psm to one_line, one_word, one_char(and chop up the picture). With one_line and one_word there was no significant change. with one_char it did recognize a bit better, but sometimes, due to big spacing it attached an extra number to it, which then screwed it up, if you look at the attached image zero.jpg then it resulted in 04. I have also tried to do the binarization myself, this resulted in poorer recognition and was very rescource consuming. I have tried to invert the pictures, this makes no difference at all for tesseract.

I have attached the pictures i'd need, among others, to be processed.

Explaination about the images:

decodethisimage_seven is a image that the tesseract has no trouble recognizing, though it has been made in word for the conveniences of building an app around a working image.

decodethisimage_eight is real life image matching the image_seven. But it cannot recognize this.

decodethisimage_four2 is another image i'd like it to recognize, and yes i know it cant be skrewed, and i did unskrew(think skrew is the term here=="straighting") it when testing.

Anders Metnik
  • 6,096
  • 7
  • 40
  • 79

3 Answers3

2

I know of some options that might help you:

  1. Add extra space between image border and text. Tesseract would work awful if text in the image is positioned at the edge.
  2. Duplicate your image. For example, if you're performing OCR on a word 'foobar', clone the image and send 'foobar foobar foobar foobar foobar' to tesseract, results would be better.
  3. Google for font training and image binarization for tesseract.

Keep in mind, that built-in camera in mobile devices mostly produce low quality images (blured, noised, skewed etc.) OCR itself is a resource comsuming process and if you add a worthy image preprocessing to that, low-end and mid mobile devices (which are likely to have android) could face unexpectedly slow performance or even lack of resources. That's OK for free/study projects, but if you're planning a commercial app - consider using a better SDK.

Have a look at this question for details: OCR for android

Community
  • 1
  • 1
Nikolay
  • 2,206
  • 3
  • 20
  • 25
  • Thanks for your input, i'll defently try it. Concerning low-end mid mobile, normal mid segment imo. has atleast 3mpix cams, and that should suffice, though the autofocus is a problem it is manageable. to avoid skewed picture i set a very limited rectangle as an overlay on my screen, so that is kind of avoided aswell. But i agree that it might be to heavy for the phone, I wouldnt mind it running on a server, i just need to know that it works first, which i havent obtained yet :-/ – Anders Metnik Apr 17 '12 at 12:20
  • Though do you have any idea how to dublicate and or add a frame to pictures? Ill start looking around for it, just if u had any experience with it allready :) – Anders Metnik Apr 17 '12 at 12:24
  • 1 and 2 didnt work. Im tossing tesseract, trying to work with javaocr instead – Anders Metnik Apr 19 '12 at 12:45
2

Tesseract doesn't do segmentation for you. Tesseract will do a thresholding of the image prior to the actual tesseract algo. After thresholding, there may be some edges, artefacts that remain in the image.

Try to manually modify your images to black and white colors and see what tesseract returns as output.

Try to threshold (automatically) your images and see what tesseract returns as output. The output of thresholding may be too bad causing tesseract to give bad output.

Your 4th image will probably fail due to thresholding (you have 3 colors: black background, greyish background and white letters) and the threshold may be between (black background, greyish background).

Generally Tesseract wants nice black and white images. Preprocessing of your images may be needed for better results.

For your first image (with the result "04"), try to see the box result (char + coordinates of box that contains the recognized char). The "0" may be a small artefact - like a 4 by 4 blob of pixels.

1

You may give javaocr a try ( http://sourceforge.net/projects/javaocr/ , yes, I'm developer )

Therre is no offocial release though, and you will have to look for sources ( good news: there is working android sample including sampler, offline trainer and recognizer application )

If you only one font, you can get pretty good results with it (I reached up to recognition rates 99.96 on digits of the same font)

PS: it is pure java and uses invariant moments to perform matching ( so no problems with scaling and rotation ) . There is also pretty effective binarisation.

See it in action:

https://play.google.com/store/apps/details?id=de.pribluda.android.ocrcall&feature=search_result#?t=W251bGwsMSwxLDEsImRlLnByaWJsdWRhLmFuZHJvaWQub2NyY2FsbCJd

Konstantin Pribluda
  • 12,329
  • 1
  • 30
  • 35
  • Tried your app, doesnt recognize any of my numbers/pictures it seems :-/ – Anders Metnik Apr 17 '12 at 12:18
  • This app is trained to black text on white backgrounds. In case you need negatives, you may try android samples in javaocr process (only slight modification is necessary in binarisation process to work with negatives) PS: can you post regcognition result screenshot? Then I maz be able to give some more hints – Konstantin Pribluda Apr 17 '12 at 12:40
  • No need it is because mine are negatives :-) – Anders Metnik Apr 17 '12 at 13:04
  • well, they you shall try android demos. – Konstantin Pribluda Apr 17 '12 at 13:10
  • also tried, have been trying yours earlier, tried to teach it multiple digital fonts. And it had big trouble with especially this one: http://www.dafont.com/silverball-oblique.font Just fyi :) – Anders Metnik Apr 17 '12 at 13:10
  • Yes, there are android apps in sources for gathering samples, teaching and recognition. Forget released version - it has nothing in common with actual codebase – Konstantin Pribluda Apr 17 '12 at 13:34
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/10178/discussion-between-anders-metnik-and-konstantin-pribluda) – Anders Metnik Apr 17 '12 at 13:39