Ask Your Question
3

good result or bad result for findHomography

asked 2012-08-02 12:13:47 -0600

andrea gravatar image

updated 2012-08-02 12:26:48 -0600

sammy gravatar image

I read that for finding that the homography is good or bad thare are 2 solution:

  1. Compute the determinant of the homography, and see if it's too close to zero for comfort.

  2. Even better, compute its SVD, and verify that the ratio of the first-to-last singular value is sane (not too high). Either result will tell you whether the matrix is close to singular.

Is this true? and there is a method to calculate the SVD in opencv?

edit retag flag offensive close merge delete

Comments

What do you mean by first-to-last ? and also can you give reference where you read it? thanks

MariGeek gravatar imageMariGeek ( 2018-01-01 03:19:02 -0600 )edit
ZettaCircl gravatar imageZettaCircl ( 2019-04-23 07:46:03 -0600 )edit

3 answers

Sort by » oldest newest most voted
3

answered 2012-08-02 13:12:33 -0600

Adi gravatar image

Algebraically, both will give the same results when the matrix is singular (or not). (2) is actually a stronger and probably better measure of quality, though you'd have to verify that the largest eigen-value isn't too small too.

OpenCV supports SVD.

edit flag offensive delete link more

Comments

How can i compute SVD and and verify that the ratio of the first-to-last singular value is sane with OpenCV?

Dirhem gravatar imageDirhem ( 2013-05-07 17:04:36 -0600 )edit
2

answered 2013-12-12 17:44:14 -0600

dma gravatar image

updated 2013-12-12 18:02:39 -0600

My understanding concerning :

  1. "Compute the determinant of the homography, and see if it's too close to zero for comfort."

Compute the determinant of the top left 2x2 homography matrix, and check if it's "too close" to zero for comfort...btw you can also check if it's *too *far from zero because then the invert matrix would have a determinant too close to zero. A determinant of zero would mean the matrix is not inversible, too close to zero would mean *singular (like you see the plane object at 90°, which is almost impossible if you use *good matches).

const double det = H.at<double>(0, 0) * H.at<double>(1, 1) - H.at<double>(1, 0) * H.at<double>(0, 1);

One way to do it would be to specify a positive value, higher than 1, say N, and then:

if((fabs(det)>(double)N) || (fabs(det)<(1.0/(double)N)) return false; // bad homography

And while we are at it...if det<0 the homography is not conserving the orientation (clockwise<->anticlockwise), except if you are watching the object in a mirror...it is certainly not good (plus the sift/surf descriptors are not done to be mirror invariants as far as i know, so you would probably don'thave good maches).

if(det<0) return false; // no mirrors in the scene

/* for reading & reference : [Detecting Planar Homographies in an Image Pair Etienne Vincent and Robert Laganiere School of Information Technology and Engineering University of Ottawa Canada K1N 6N5] */

edit flag offensive delete link more

Comments

thank you for clear answer with reference.

MariGeek gravatar imageMariGeek ( 2018-01-01 01:05:04 -0600 )edit

What is N here?

MariGeek gravatar imageMariGeek ( 2018-01-01 03:04:26 -0600 )edit

It's a threshold, it's written.

ZettaCircl gravatar imageZettaCircl ( 2019-04-23 07:47:48 -0600 )edit
0

answered 2018-01-05 09:02:42 -0600

niccer gravatar image

To my experience, it is hard to choose thresholds (e.g. N) such that outliers are removed, but (bad) correct estimates are kept.

If you estimate the homography for a rectangular template, you can draw a quadrangle given by the corner points of this template. Outliers can be identified from quadrangles with self-overlap or extreme corner angles (e.g. >170° or < 30°).

It shouldn't be too hard to check these conditions, but I do not have a code example right now.

edit flag offensive delete link more

Question Tools

4 followers

Stats

Asked: 2012-08-02 12:13:47 -0600

Seen: 4,300 times

Last updated: Dec 12 '13