Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using OpenCV, how can I detect text orientation before performing OCR?

I'm using OpenCV within an iOS application. I'd like to perform OCR on some text, but I first need to determine its orientation.

How do I do that in OpenCV?

like image 971
Mustafa Ibrahim Avatar asked Dec 10 '22 01:12

Mustafa Ibrahim


1 Answers

I am not sure that one can reply to the question without providing OCR in Objective-C - something that can hardly be done in a few lines of text without using an OCR library.

Well, 20 years ago, I wrote an OCR system (without using any OCR library) to read bank checks in real-time. It was also authentifying hand-written signatures by the way.

The problem of checking the orientation was pregnant because checks could be inserted randomly (by human operators) in the small motorized bank-check scanner.

Since all banks were using different page layouts and decorations, the only way to find the orientation without relying on magnetic ink (that the scanner did not detect) was to actually attempt an OCR recognition on the first characters found at the top of the 'page'.

Some charcters are ambiguous like an 'O' but most others will tell you if the picture is inverted or mirrored so just reading the first 3-5 charcters will do the job (unless you have repetitions).

Good luck!

like image 169
Gil Avatar answered May 20 '23 10:05

Gil