8

How to find image "A" coordinates on image "B" which contains image "A".

I wrote this program which is only checking pixel values, does anyone know is there any library tool do this.

oberfreak
  • 1,799
  • 13
  • 20
haykart
  • 957
  • 5
  • 14
  • 34

3 Answers3

6

As Throwback1986 suggested, you will probably want to use matchTemplate. Here is one of my answers showing how to detect the Sun from virtual spacecraft. Here is the newer tutorial from OpenCV on using matchTemplate. Now, there are some caveats for using the matchTemplate approach. If image "A" can be at an arbitrary pose (e.g., changes in scale, rotation, perspective, etc) in image "B", then matchTemplate isn't going to work very well. If that happens to be the case, you will want to use to go the feature detection route as suggested by Adrian Popovici.

Community
  • 1
  • 1
mevatron
  • 13,911
  • 4
  • 55
  • 72
  • 1
    thank you I would check links and tutorials. I am grateful to you for help. Your answer is most helpful for me, because of that I accept your answer. thank you for spending time to answer my question. – haykart Dec 08 '11 at 12:15
5

You should take a look at the last 3 tutorials from this link: http://opencv.itseez.com/doc/tutorials/features2d/table_of_content_features2d/table_of_content_features2d.html

I don't think the checking of pixels is a good approach.

Adrian
  • 2,028
  • 2
  • 17
  • 28
0

You might consider something like template matching as described in this tutorial.

A more brute force approach would be to "slide" image A incrementally over image B looking for the point of least difference. (Note that this assumes image A is some reasonably small subset of image B.) You can use the cvNorm function to compute the L1 norm, which is equivalent to computing the Sum of Squared Differences (SSD). Use the CV_L1 option. Here is a link describing the application of SSD in image correlation.

Throwback1986
  • 5,887
  • 1
  • 30
  • 22
  • thank you I would check links, your answer helped me. I am grateful to you for help. thank you for spending time to answer my question. – haykart Dec 08 '11 at 12:13