0

How to detect logos if they are distorted (i.e. stretch, rolled, squeezed)?

I used SIFT as features for detection, as it is scaled invariant.

Below is an example, the logo appears in the bottle, it is stretched along the bottle's curvature.

An also, the material of the product will also affect the result, for example, it may reflect the light.

How to solve these two problems? I would appreciate it if someone could give me the detail steps, thanks!

Logo:

enter image description here

Example:

enter image description here

kim
  • 73
  • 2
  • 7
  • 1
    probably related: http://xkcd.com/1425/ – cel Mar 18 '15 at 10:42
  • This is not directly related but might give you some ideas: [Algorithm improvement for Coca-Cola can shape recognition](http://stackoverflow.com/q/10168686/2545927) – kkuilla Mar 18 '15 at 11:29

2 Answers2

0

I think that you should make situation a little bit easier before trying to detect logo - a good point to start might be applying perspective transform to make logo less distorted. Here is code which applys perspective transofrm to image:

import cv2
import numpy as np

src = np.array([[8,125], [68,30], [576,261], [510,396]], np.float32)
dst = np.array([[0,0], [100, 0], [100, 400], [0, 400]], np.float32)
perspective_transform = cv2.getPerspectiveTransform(src, dst)
img = cv2.imread('d:\\temp\\logo_lamer.png')
final_img = cv2.warpPerspective(img, perspective_transform, (100, 400))
cv2.imwrite('d:\\temp\\logo_lamer2.png', final_img)

Points are hardcode, but finding them shouldn't be very hard - i've just used left-most, top-most, right-most and bottom-most points of the bottle. Here is image with points:
enter image description here
and here is the result of transformation:
enter image description here
As you can see it's not perfect (letters "L" and "R" are not fully visible), but it can be imporoved using some good for object extraction. Using grabcut might be a good idea, but most likely a lot of techniques will perform well in this situation. Alternatively after finding points you can try to just make sure that they form a (rotated) rectangle, so make sure that all angles are equal (or close to) 90 degress - here is how you can do it.

Now it should be much easier to apply some technique from this qeustion (i would try scanline and sift/surf techniques, but it's just my guess). Alternatively you can try to use Generalized Hough Transfom(GHT), template matching or train you own classifier using Haar-like features, LBP(local binary patterns) or HOG.

Community
  • 1
  • 1
cyriel
  • 3,522
  • 17
  • 34
0

In your question you say that you use SIFT. The results are not good enough?

Using the SIFT detector and descriptor I got this results:

SIFT matching result

Not good enough?

zedv
  • 1,459
  • 12
  • 23