Ask Your Question
1

Multiple object detection with 2D features and homography?

asked 2012-10-10 09:04:04 -0600

icedecker gravatar image

updated 2012-10-10 09:05:17 -0600

The code showed in the tutorial about 2D features and homography, the SURF_Homography.cpp can be adapted to detect multiple occurrences of the same object on a image?

I'm trying to figure a good way to do this:

1 - I have the list of matched features

2 - When I find the first object, calculate the homography

3 - Delete the matched features inside the homography.

4 - Iterate until I don't have any matched features.

The problem is that I don't have much idea how to do the step 3, how to know if keypoints are inside of a homography region? Anyone have idea how to do it, or have a better algorithm?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2012-10-10 09:54:42 -0600

Ben gravatar image

Assuming the code from the tutorial, you can get the inliers for a homography like this:

Mat inliers;
Mat H = findHomography( obj, scene, CV_RANSAC, ransacReprojThres, inliers );

for (int i=0; i<inliers.rows; ++i)
{
    if (inliers.at<uchar>(i,0) != 0)
    {
        // good_matches[i] is an inlier
    }
}

But I doubt that you will get the results you are expecting. Having multiple objects of the same type in one image will increase the number of "false" matches. Your template image's features will match to multiple objects in the target image and thus make it difficult to find a good homography.

Depending on how similar your objects are, you might consider another method. Do you need rotation invariance? Do you need scale invariance? Maybe template matching is a better option for you.

edit flag offensive delete link more

Comments

At least I need scale invariance... rotation not much. I've tried template matching but I did not get good results. Anyway, thanks for the reply, Ben! I will see what I can do.

icedecker gravatar imageicedecker ( 2012-10-10 15:13:11 -0600 )edit

Question Tools

Stats

Asked: 2012-10-10 09:04:04 -0600

Seen: 2,479 times

Last updated: Oct 10 '12