Object detection for specific flat objects
Asked Answered
V

1

10

I'm new to computer vision, and I want to detect specific and flat objects in an image (or video frame).

What do I mean with specific and flat?

Flat

Well, flat objects are like objects, but, you know, flat... What it means to me:

  • Objects will always be viewed from approximately the same "frontal" angle, that is, the axis of the camera corresponds (more or less) with their surface normal. (But they may be rotated around that axis).
  • Objects for which the angle of illumination doesn't change anything (i.e. it doesn't have bumps and creases that cast shadows).

Specific

  • Ojects of which I know the exact appearance and shape. They are all exactly the same, there are no variations.
  • I have a (precise) photograph (or representation) of them.

Examples of such objects

  • The obverse of a $1 bill
  • The Mona Lisa
  • The front cover of the last issue of (your favorite magazine here)
  • ...

I believe the problem is easy enough that I should be able to find a function of a computer vision library that basically works like that:

> findObjects("object.png", "image.png")
[object at x1, y1, rotated z1 degrees, size height1*width1,
 object at x2, y2, rotated z2 degrees, size height2*width2,
 ...]

In fact I don't even really care about the sizes and locations of the objects, I just need a count.

But I can't find anything like this. All I can find are countless examples of face recognition with something called a Haar-classifier, which doesn't seem appropriate for my problem at all, because:

  • Faces are not flat, and thus that classifier must cope with problems like different illuminations, shadows...
  • It must recognize faces, that is, objects that are similar, but not exactly identical.
  • It must recognize faces that it hasn't been trained with just because they "look like" faces.
  • Proof that this is not suited: it must be trained with hundreds or thousands of positive and negative samples. In my problem, all the information needed is contained in a single sample. So that can't be right.

So, does something like this exists?

I'd prefer to use OpenCV since this seems to be the standard computer-vision library, but I am open to any solution.

Vicarage answered 20/2, 2011 at 17:25 Comment(0)
S
6

One way to do that would be to use a keypoint matcher. Opencv has a demo doing kind-of what you want (find https://i.sstatic.net/FUCEm.jpg in https://i.sstatic.net/8Bz9F.jpg as a premade demo (in the opencv 2.2 distribution: samples/c/find_obj.cpp). The output is visualized in https://i.sstatic.net/SjcPl.jpg - you should be able to start from that to adapt it so it finds multiple instances of the image and counts them.

Shadowgraph answered 20/2, 2011 at 17:38 Comment(2)
Thanks, it works OK, but not great. For example, it doesn't take color into account, which could help a lot. But your pointing me at this sample made me find some keywords to search for (SURF, SIFT, planar object detection...). Thanks!Vicarage
@Gohu: It shouldn't be too hard to include color information into the feature. However, be careful with colors: If the camera or the illumation changes, colors change. It isn't as obvious for us humans, but it's a hard problem for computers, see en.wikipedia.org/wiki/Color_constancyShadowgraph

© 2022 - 2024 — McMap. All rights reserved.