Ask Your Question
5

Check if homography is good

asked 2012-09-25 04:20:37 -0600

yes123 gravatar image

updated 2012-09-25 05:24:35 -0600

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 flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2012-09-25 08:36:46 -0600

Rui Marques gravatar image

updated 2012-09-25 08:37:42 -0600

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.
edit flag offensive delete link more

Comments

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

yes123 gravatar imageyes123 ( 2012-09-25 09:32:17 -0600 )edit

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

Rui Marques gravatar imageRui Marques ( 2012-09-25 12:14:32 -0600 )edit

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

MariGeek gravatar imageMariGeek ( 2017-11-29 17:55:55 -0600 )edit

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

MariGeek gravatar imageMariGeek ( 2017-11-29 17:59:33 -0600 )edit

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

MariGeek gravatar imageMariGeek ( 2017-11-29 18:13:18 -0600 )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 ( 2019-04-23 08:16:35 -0600 )edit

Question Tools

2 followers

Stats

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

Seen: 7,137 times

Last updated: Sep 25 '12