4

I have a large image (5400x3600) that has multiple CCTVs that I need to detect.

The detection takes lot of time (4-7 minutes) with rotation. But it still fails to resolve certain CCTVs.

What is the best method to match a template like this?

I am using skImage - openCV is not an option for me, but I am open to suggestions on that too.

For example: in the images below, the template is correct matched with the second image - but the first image is not matched - I guess due to the noise created by the text "BLDG..."


Template:

Template


Source image:

Source image


Match result:

Match result

Community
  • 1
  • 1
anups
  • 583
  • 1
  • 7
  • 18
  • Did you try to use preprocessing of your image, such as [thresholding](https://en.wikipedia.org/wiki/Adaptive_thresholding)?. This could reduce the noise. I also noticed that the rotation was a flip about the x-axis, you could maybe speed up the detection if the rotations are only 4 fixed rotations, by searching only for these 4 options. – spoorcc Mar 11 '14 at 08:51
  • I converted the image with only black/white pixels. If that is what you mean. Rotation itself isn't taking time. I need full 360 degrees - but I am unable to go below 10 degree increment since matching an entire image takes 9 seconds per template( and 5 seconds on another machine). I haven't multi threaded yet - so that is a point of improvement - my target is to take it down to 3 mins overall on two-cores. – anups Mar 11 '14 at 09:05
  • Indeed I meant the black/white conversion, so only 0 or 255. It is certainly a candidate for multithreading, since you do 36 independent operations. Just fire-off a thread for each rotation. OpenCV is not an optin for you, but you will take answers implemented using it? – spoorcc Mar 11 '14 at 09:21
  • Create a cascade classifier. Sliding window Test1: number of black pixels, Test2: convolution with template (or 360 rotated templates). cv::countNonZero and cv::matchTemplate will do the work. – LovaBill Mar 11 '14 at 09:48
  • When testing different rotations, do you rotate the template or the search image? I would recommend keeping the template axis-aligned, that way you have a smaller bounding box, which should be less susceptible to noise. – HugoRune Mar 11 '14 at 17:48

4 Answers4

2

The fastest method is probably a cascade of boosted classifiers trained with several variations of your logo and possibly a few rotations and some negative examples too (non-logos). You have to roughly scale your overall image so the test and training examples are approximately matched by scale. Unlike SIFT or SURF that spend a lot of time in searching for interest points and creating descriptors for both learning and searching, binary classifiers shift most of the burden to a training stage while your testing or search will be much faster.

In short, the cascade would run in such a way that a very first test would discard a large portion of the image. If the first test passes the others will follow and refine. They will be super fast consisting of just a few intensity comparison in average around each point. Only a few locations will pass the whole cascade and can be verified with additional tests such as your rotation-correlation routine.

Thus, the classifiers are effective not only because they quickly detect your object but because they can also quickly discard non-object areas. To read more about boosted classifiers see a following openCV section.

Vlad
  • 4,425
  • 1
  • 30
  • 39
0

This problem in general is addressed by Logo Detection. See this for similar discussion. There are many robust methods for template matching. See this or google for a very detailed discussion.

But from your example i can guess that following approach would work.

  1. Create a feature for your search image. It essentially has a rectangle enclosing "CCTV" word. So the width, height, angle, and individual character features for matching the textual information could be a suitable choice. (Or you may also use the image having "CCTV". In that case the method will not be scale invariant.)

  2. Now when searching first detect rectangles. Then use the angle to prune your search space and also use image transformation to align the rectangles in parallel to axis. (This should take care of the need for the rotation). Then according to the feature choosen in step 1, match the text content. If you use individual character features, then probably your template matching step is essentially a classification step. Otherwise if you use image for matching, you may use cv::matchTemplate.

Hope it helps.

Community
  • 1
  • 1
Dib
  • 317
  • 1
  • 4
  • 13
0

Symbol spotting is more complicated than logo spotting because interest points work hardly on document images such as architectural plans. Many conferences deals with pattern recognition, each year there are many new algorithms for symbol spotting so giving you the best method is not possible. You could check IAPR conferences : ICPR, ICDAR, DAS, GREC (Workshop on Graphics Recognition), etc. This researchers focus on this topic : M Rusiñol, J Lladós, S Tabbone, J-Y Ramel, M Liwicki, etc. They work on several techniques for improving symbol spotting such as : vectorial signatures, graph based signature and so on (check google scholar for more papers).

An easy way to start a new approach is to work with simples shapes such as lines, rectangles, triangles instead of matching everything at one time.

Olivier A
  • 842
  • 4
  • 8
-1

Your example can be recognized by shape matching (contour matching), much faster than 4 minutes.

For good match , you require nice preprocess and denoise.

examples can be found http://www.halcon.com/applications/application.pl?name=shapematch

minorlogic
  • 1,872
  • 1
  • 17
  • 24