First time here? Check out the FAQ!

Ask Your Question
5

Check if homography is good

asked Sep 25 '12

yes123 gravatar image

updated Sep 25 '12

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

Preview: (hide)

1 answer

Sort by » oldest newest most voted
4

answered Sep 25 '12

Rui Marques gravatar image

updated Sep 25 '12

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.
Preview: (hide)

Comments

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

yes123 gravatar imageyes123 (Sep 25 '12)edit

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

Rui Marques gravatar imageRui Marques (Sep 25 '12)edit

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

MariGeek gravatar imageMariGeek (Nov 29 '17)edit

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

MariGeek gravatar imageMariGeek (Nov 29 '17)edit

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

MariGeek gravatar imageMariGeek (Nov 30 '17)edit

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)

ZettaCircl gravatar imageZettaCircl (Apr 23 '19)edit

Question Tools

2 followers

Stats

Asked: Sep 25 '12

Seen: 7,367 times

Last updated: Sep 25 '12