Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.