37

With my new assignment I am looking for a method to detect the presence of text on image. The image is a map - can be for example google map. The task is to detect where the street/city label is placed.

I know that opencv library has algorithm that can detect features (for example human faces) - haar classifier or hog (histogram of oriented gradients), but I heard that learning process of such algorithms is quite difficult.

Do you know of any algorithm, method or a library that could do that (detect presence of text on image)?

Thanks, John

Community
  • 1
  • 1
John
  • 371
  • 1
  • 3
  • 3

3 Answers3

21

There is a standard problem in vision called text detection in images. it is quite different to OCR. OCR concerms itself with what it says, while text detection is about determining if there is text in the image. Adi Shavit's third link is a method to address this problem. You can look on google scholar well cited articles on text detection.

carlosdc
  • 12,022
  • 4
  • 45
  • 62
16

There are several possible approaches you can take.

  1. Use OCR. A search for OCR on Stackoverflow will show many options. These include Tesseract and Ocropus.
  2. If your text uses very specific fixed font, you may get away with simple template matching.
  3. In the more general case you might want to take a look at "Detecting Text in Natural Scenes with Stroke Width Transform"

UPDATE Jan. 2017
The OpenCV 3.2 contrib module now has a text detection module.
It also includes a sample (C++, Python) of how to use it.

rinogo
  • 8,491
  • 12
  • 61
  • 102
Adi Shavit
  • 16,743
  • 5
  • 67
  • 137
  • Ocropus can convert the found letters to the actual text, but won't help find the letters in the first place. Simple template matching with an added restriction that requires at least two characters close to each other on a horizontal line will work very well for the google map case. – jilles de wit Jan 06 '11 at 13:44
  • 2
    Epshtein et al. paper (Stroke Width Transform) has been implemented and shared by [Saurav & Andrew](http://stackoverflow.com/questions/4837124/stroke-width-transform-swt-implementation-java-c/5599470#5599470). – Kaushik Acharya Oct 15 '11 at 07:03
  • 1
    Here is a python implementation of the example using the python opencv wrapper https://github.com/opencv/opencv_contrib/blob/master/modules/text/samples/textdetection.py – parsethis Feb 09 '17 at 17:27
0

You need to tune this to a specific type of map images, or the problem is going to be very difficult (see the previous post about links to articles).

OCR is the way to go, and you should use an existing library. However, OCR is mainly done on text on white backgrounds. To reduce your problem to a regular OCR problem, you should attempt to work on the color space of the map. Likely the map text has a very specific color and this may be enough to find these pixels. You can then filter the detected pixels based on the size of connected regions.

If you literally only want to find the locations of text labels, you can do the above, and pretty much just skip the OCR step. If the labels are not too close, simple clustering algorithms can be used to find their respective positions.

mahogny
  • 79
  • 1
  • 2