8

I am struggling with tesseract ocr on ios. Everything works fine but it is really slow. 2 - 3 seconds recogintion time for a single line of digits.

I am reading from a Video Stream.

I am using tesseract 3.01 with a custom training file for my font.

Here is what I do:

Setting up tesseract only to find numbers (0-9)

  1. Shrink, Deskew and Binarize Image
  2. use GetLines to find the line I want the text of
  3. setRectangle to only recognize the line i want
  4. getUTF8Text to get my text <- this alone takes 2-3 seconds

Are there any suggestions to speed up the process?

n3utrino
  • 2,361
  • 3
  • 22
  • 32
  • 2
    I've heard about people getting faster results when doing a prepass with an adaptive threshold on the image containing the text and then sending that binarized image into Tesseract. This question talks about that topic, as an example: http://stackoverflow.com/questions/9992078/converting-a-uiimage-blackn-white-and-not-grayscale-for-using-tesseract – Brad Larson Jul 24 '12 at 14:49
  • Thank you for your suggestion, I forgot to mention this is done on point 1. will update my question. – n3utrino Jul 25 '12 at 05:35

2 Answers2

7

I switched to the SVN of tesseract 3.02

After having some problems with crosscompiling,

I am down to about 1.2 - 0.8 Seconds for getUTF8Text and 0.3 - 0.2 seconds for image preprocessing.

I did some testing

  • Binarization and Shrinking by 0.7 gains 0.3 Seconds but costs you 0.1
  • chop_enable=0 has almost no effect on speed about a speed gain of 0.1 in average althoug it counts for 50% of the cpu usage if profiled

The main gain in usability was to optimize the code with setRectangle not calling getUTF8Text if I suspect the bounds to be incorrect. And some String postprocessing by checking the received string and apply some algorithm to eliminate the most common misinterpretations from tesseract.

maybe this is useful for someone else.

n3utrino
  • 2,361
  • 3
  • 22
  • 32
  • can you please explain "...optimize the code with setRectangle not calling getUTF8Text..." ? Do you mean that you checked rectangle bounds 1st and if they appeared suspect to you, you would not call getUTF8Text? – Thompson Jun 01 '13 at 00:53
  • @Thompson yes this is what I did. But now I find the line I want to process. Then process all the chars boxes on their own and discard all boxes that have a confidence rating below 20 so I don't get garbage. It is even faster now. – n3utrino Jun 11 '13 at 09:01
0

One thing you might want to try is do it in the background. It will not improve the recognition speed, but by having the user do something else it might appear faster. This, of course, depends on the use case (I have one where this is a nice improvement as it seems very fast, while I just start sooner than expected). The trick is that ios apps are about perceived performance, not actual performance (although it naturally has a big impact on perceived performance).

bartvdo
  • 9
  • 2