How can I get an estimate of how good is the homography that I get using findHomography?

asked 2016-04-07 04:37:17 -0600

nyd gravatar image

The question is kinda giving it away, but I use:

H = findHomography(obj, scene, RANSAC, 1);

and it would be nice if I could get some sort of a statistical measure, like the back-projection error. Any ideas?

edit retag flag offensive close merge delete

Comments

I don't think there is a built-in function that could do that, but you could easily code it yourself.

Eduardo gravatar imageEduardo ( 2016-04-07 09:10:27 -0600 )edit

The algorithm must also calculates the back-projection error, so it would be nice if it would also return it somehow. What do you mean by I could easily calculate it myself? I don't know what are the final tiepoints selected after RANSAC in findHomography, so how could I calculate it?

nyd gravatar imagenyd ( 2016-04-08 04:28:05 -0600 )edit

You have the mask parameter for that.

Eduardo gravatar imageEduardo ( 2016-04-08 06:56:02 -0600 )edit

thank you for the hint. So, all I have to do now is to recalculate the homography on my own using the points in the mask and get the error, while I'm doing this. It is at least weird to calculate homography twice, only to get the error, and if I am creating a function that does this, I might as well write it straight into OpenCV and make a pull request

nyd gravatar imagenyd ( 2016-04-08 08:08:31 -0600 )edit

Not sure to understand you correctly.

No need to recalculate the homography (I understand calculate homography the process that allows to get the matrix H). You just have to transform each inlier source point with the homography matrix returned, and get the distance error between the computed point and the destination point.

computed_pt = H * source_pt
error_pt = sqrt( (computed_pt.x - dst_pt.x)*(computed_pt.x - dst_pt.x) + (computed_pt.y - dst_pt.y)*(computed_pt.y - dst_pt.y) )

Indeed, you could if you want submit a pull request that allows to get the mean reprojection error as a parameter.

Eduardo gravatar imageEduardo ( 2016-04-08 16:48:37 -0600 )edit