0

I read the card using OCR on Android(or iOS). But in the process, if it is successful it is not upside down. But character is wrong, the process fails. I am using tesserat and opencv algoritms.

Example like this image. How i can detect text orientation and rotate image.

enter image description here

Junior Develepor
  • 192
  • 2
  • 18

1 Answers1

0

If the OCR technology you are using does not have a dedicated auto-rotate function (most do, so double-check), then the technique I use is to check for either character confidence or to check for words from dictionary. ABBYY OCR, for example, has a dedicated auto-rotate setting. OCR-IT API also has auto-rotate, and also can return flags such as IsWordFromDictionary in the XML result. Every OCR technology may work differently.

If you expect only 4 possible rotations, then the algorithm is:

  1. Perform OCR. Check confidence, or dictionary words, or even just capitalization (incorrect rotation will produce mess like this: DioOpUllltG). Set a threshold over which you accept the result, such as 50%. You are hoping that your first OCR pass is from an image in correct orientation (statistical approach).
  2. If quality is lower than your threshold, then either you have a low quality image in correct orientation, or the orientation is wrong. Rotate and check remaining three orientations. Pick the best one.

In some projects, where images may be at unpredictable extreme angles, such as 30 degrees, OCR will fail in every case when performing 4 flips. Then I usually use an OCR pass at every 10 degrees rotation (36 OCR passes), and pick the best case.

Ilya Evdokimov
  • 1,374
  • 11
  • 14
  • Suggestions correct. A viable solution.I thought I try 4 different states.And I try. But the high cost for the OCR process is not fast(Tesseract OCR not so fast enough. ). Time is growing too. – Junior Develepor Dec 14 '15 at 10:09