2

I am using Robert Theis' experimental app (namely, android-ocr) to achieve real-time OCR and translation (using Bing translator.)

In class CaptureActivity.java, in function handleOcrContinuousDecode (which is the function for real-time OCR), I have created a TranslateAsycnTask.java object which passes the translated-text to be displayed through the ViewFinderView.java like this:

The problem I'm getting is that after the first successful real-time translation, the result of the first translation is displayed for the next translation(s). The OCR performed is however, successful for all the next cases. Like this:

What's happening here is the OCR text is on the top left for "velocity"and the translated text "velocidad" is drawn over the original text. In case of "application", the OCR displayed is correct however the translation returned is of the previous case.

Kindly tell me what am I doing wrong or how or what should I do to solve this problem?

Thanks.

Rami
  • 7,879
  • 12
  • 36
  • 66

1 Answers1

0

You're not allowing for the time required to perform the translation using Bing over the Internet.

Because of the delay required for translation, you don't yet have the translated text when you draw to the viewfinder the first time. When you call execute() on your AsyncTask, that begins the translation process asynchronously, execution continues, and you write to the viewfinder with a null value in globalString.

Then the OCR process loops, requesting several more translations for your first word velocity before you even point the camera at your second word. After a delay, your first translation 'velocidad' comes back and is assigned to globalString which is picked up and displayed after you have run through the loop a few times.

Because you do OCR of one word faster than you can translate one word, by the time you point your camera at your second word you've already requested a translation for the same word 'velocity' many times and bogged things down.

rmtheis
  • 5,992
  • 12
  • 61
  • 78
  • Sir, sorry to take your time, but can you think of a solution on how to tackle this problem? – Marij Siddiqui Apr 30 '15 at 13:01
  • You could try caching translation results in a HashMap that maps the recognized text to the translated text. Then you could avoid creating a new translation request for text that you've already translated. – rmtheis Apr 30 '15 at 14:14