Trouble recognizing digits in Tesseract - android

2019-03-13 14:39发布

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.

3条回答
劫难
2楼-- · 2019-03-13 14:56

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

查看更多
做个烂人
3楼-- · 2019-03-13 15:14

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.

查看更多
做自己的国王
4楼-- · 2019-03-13 15:14

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

查看更多
登录 后发表回答