Ask Your Question
4

check ransac outlier before perspectiveTransform ?

asked 2012-08-20 16:17:05 -0500

yes123 gravatar image

updated 2018-08-30 10:55:30 -0500

Hello guys,

I would like to draw outliers found by ransac with the classic method:

H = findHomography( obj, scene, CV_RANSAC );

I saw in a snippet one can do something like:

Mat points1t; perspectiveTransform(Mat(points1), points1t, H12);
for( size_t i1 = 0; i1 < points1.size(); i1++ ) {
    if( norm(points2[i1] - points1t.at<Point2f>((int)i1,0)) <= maxInlierDist ) // inlier
        matchesMask[i1] = 1;
}

But I don't understand why we need to call perspectiveTransform to find out which are the outlier if the outlier themself are calculted with the precedent istruction (findHomography) ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2012-08-20 17:19:53 -0500

yes123 gravatar image

updated 2012-08-20 17:20:43 -0500

Ok I found the solution (It's undocumented)

the 4th param of findHomography returns a vector<uchar> mask where inliners are marked with 255.

You can use something like to draw outliers

        for(unsigned int i = 0; i<scene.size();i++) {
            if (!mask[i]) //> Outlier
                circle(frame,scene[i],8,Scalar(0,0,255),3);
        }
edit flag offensive delete link more

Comments

Login/Signup to Answer

Question Tools

Stats

Asked: 2012-08-20 16:17:05 -0500

Seen: 2,173 times

Last updated: Aug 20 '12