Check if homography is good

Basically I a am using a function

bool niceHomography(const CvMat * H)
{
const double det = cvmGet(H, 0, 0) * cvmGet(H, 1, 1) - cvmGet(H, 1, 0) * cvmGet(H, 0, 1);
if (det < 0)
return false;

const double N1 = sqrt(cvmGet(H, 0, 0) * cvmGet(H, 0, 0) + cvmGet(H, 1, 0) * cvmGet(H, 1, 0));
if (N1 > 4 || N1 < 0.1)
return false;

const double N2 = sqrt(cvmGet(H, 0, 1) * cvmGet(H, 0, 1) + cvmGet(H, 1, 1) * cvmGet(H, 1, 1));
if (N2 > 4 || N2 < 0.1)
return false;

const double N3 = sqrt(cvmGet(H, 2, 0) * cvmGet(H, 2, 0) + cvmGet(H, 2, 1) * cvmGet(H, 2, 1));
if (N3 > 0.002)
return false;

return true;
}

to check whatever the homography is good or not (I have taken it from BRIEF_demo). Can anyone explain why we check the determinant like that, is there any theory behind it?

To understand what I am talking about, that function avoids homography like this: Thanks

edit retag close merge delete

Sort by » oldest newest most voted I can partially explain that, this explanation was taken from the book "Multiple View Geometry".

Property of an affine (and projective?) transformation:

• If the determinant of the top-left 2x2 matrix is > 0 the transformation is orientation-preserving.
• Else if the determinant is < 0, it is orientation-reversing.
more

Hmm thanks a lot! anyway i think we have a 3x3 Matrix as explained by opencv doc

The answer means the top-left 2x2 matrix inside the 3x3 Matrix.

and if those two conditions are not satisfied then homography matrix is wrong?

In my knowledge, if vertical lines are not vertical then homography matrix is not good. Is this correct?

Or you mean if we preserve orientation then homography matrix is good?

The homography matrix is not good in itself. It really depends on the use case. If you are trying to match pictures in a mirror, then a "orientation-reversing" homography is needed and other should be discarded. (For example)

Stats

Asked: 2012-09-25 04:20:37 -0500

Seen: 5,138 times

Last updated: Sep 25 '12