Question

I'm using OpenCV C++, in VS2010 for a face recognition application. For that, I used SURF, BruteForceMatcher.

BFMatcher matcher;
    vector< DMatch > matches;

//match: execute the matcher!
    matcher.match(descriptors1,descriptors2, matches);

I want to know what exactly happens when I call this method. My gesture is "matches" vector will be filled with the matching key points.

And

Is there anyway I can use this "matches" vector to find the good matches?
Currently, I'm doing something like this, to get minimum distance and maximum distance:

for( int i = 0; i < descriptors1.rows; i++ )
    { 
        double dist = matches[i].distance;
        if( dist < min_dist ) min_dist = dist;
        if( dist > max_dist ) max_dist = dist;
    }

If my above approach is correct, how can I use minimum distance and maximum distance to check whether the images are matching.

Thanks.

I would be grateful, if anyone can sought out this for me. Thanks.

Was it helpful?

Solution

You can try to match the images with knnMatch() method, calculating the two nearest neighbors. For each descriptor in the first image you will have 2 closest matches in second image.

These matches are the two best ones based on distance between their descriptors. If the distances of these matches are similar, it is possible that you will select the wrong one. In that case, you should discard those matches. You can do that by checking the distance ratio. If ratio of distances between first match and second match is not greater than a chosen threshold you should discard those matches. Afterwards you can do for example a RANSAC test to get even better results.

OTHER TIPS

SURF features tend to be matched using Fast Approximate Nearest Neighbour Search. There's a tutorial on using it on the opencv site here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top