haykart
haykart

Reputation: 957

opencv finding image cordinates on another image

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.

Upvotes: 8

Views: 17247

Answers (3)

mevatron
mevatron

Reputation: 14011

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.

Upvotes: 6

Throwback1986
Throwback1986

Reputation: 5995

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.

Upvotes: 0

Adrian
Adrian

Reputation: 2036

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.

Upvotes: 4

Related Questions