OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Tue, 23 Apr 2019 08:16:35 -0500Check if homography is goodhttp://answers.opencv.org/question/2588/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:
<img src="http://answers.opencv.org/upfiles/13437459121569863.png" width="70%">
ThanksTue, 25 Sep 2012 04:20:37 -0500http://answers.opencv.org/question/2588/check-if-homography-is-good/Answer by Rui Marques for <p>Basically I a am using a function </p>
<pre><code>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;
}
</code></pre>
<p>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?</p>
<p>To understand what I am talking about, that function avoids homography like this:</p>
<p><img src="http://answers.opencv.org/upfiles/13437459121569863.png" width="70%"></p>
<p>Thanks</p>
http://answers.opencv.org/question/2588/check-if-homography-is-good/?answer=2600#post-id-2600I 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.Tue, 25 Sep 2012 08:36:46 -0500http://answers.opencv.org/question/2588/check-if-homography-is-good/?answer=2600#post-id-2600Comment by ZettaCircl for <p>I can partially explain that, this explanation was taken from the book "Multiple View Geometry".</p>
<p>Property of an affine (and projective?) transformation:</p>
<ul>
<li>If the determinant of the top-left 2x2 matrix is > 0 the transformation is orientation-preserving.</li>
<li>Else if the determinant is < 0, it is orientation-reversing.</li>
</ul>
http://answers.opencv.org/question/2588/check-if-homography-is-good/?comment=212022#post-id-212022The 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)Tue, 23 Apr 2019 08:16:35 -0500http://answers.opencv.org/question/2588/check-if-homography-is-good/?comment=212022#post-id-212022Comment by MariGeek for <p>I can partially explain that, this explanation was taken from the book "Multiple View Geometry".</p>
<p>Property of an affine (and projective?) transformation:</p>
<ul>
<li>If the determinant of the top-left 2x2 matrix is > 0 the transformation is orientation-preserving.</li>
<li>Else if the determinant is < 0, it is orientation-reversing.</li>
</ul>
http://answers.opencv.org/question/2588/check-if-homography-is-good/?comment=179412#post-id-179412Or you mean if we preserve orientation then homography matrix is good?Wed, 29 Nov 2017 18:13:18 -0600http://answers.opencv.org/question/2588/check-if-homography-is-good/?comment=179412#post-id-179412Comment by MariGeek for <p>I can partially explain that, this explanation was taken from the book "Multiple View Geometry".</p>
<p>Property of an affine (and projective?) transformation:</p>
<ul>
<li>If the determinant of the top-left 2x2 matrix is > 0 the transformation is orientation-preserving.</li>
<li>Else if the determinant is < 0, it is orientation-reversing.</li>
</ul>
http://answers.opencv.org/question/2588/check-if-homography-is-good/?comment=179411#post-id-179411In my knowledge, if vertical lines are not vertical then homography matrix is not good. Is this correct?Wed, 29 Nov 2017 17:59:33 -0600http://answers.opencv.org/question/2588/check-if-homography-is-good/?comment=179411#post-id-179411Comment by MariGeek for <p>I can partially explain that, this explanation was taken from the book "Multiple View Geometry".</p>
<p>Property of an affine (and projective?) transformation:</p>
<ul>
<li>If the determinant of the top-left 2x2 matrix is > 0 the transformation is orientation-preserving.</li>
<li>Else if the determinant is < 0, it is orientation-reversing.</li>
</ul>
http://answers.opencv.org/question/2588/check-if-homography-is-good/?comment=179409#post-id-179409and if those two conditions are not satisfied then homography matrix is wrong?Wed, 29 Nov 2017 17:55:55 -0600http://answers.opencv.org/question/2588/check-if-homography-is-good/?comment=179409#post-id-179409Comment by Rui Marques for <p>I can partially explain that, this explanation was taken from the book "Multiple View Geometry".</p>
<p>Property of an affine (and projective?) transformation:</p>
<ul>
<li>If the determinant of the top-left 2x2 matrix is > 0 the transformation is orientation-preserving.</li>
<li>Else if the determinant is < 0, it is orientation-reversing.</li>
</ul>
http://answers.opencv.org/question/2588/check-if-homography-is-good/?comment=2621#post-id-2621The answer means the top-left 2x2 matrix inside the 3x3 Matrix.Tue, 25 Sep 2012 12:14:32 -0500http://answers.opencv.org/question/2588/check-if-homography-is-good/?comment=2621#post-id-2621Comment by yes123 for <p>I can partially explain that, this explanation was taken from the book "Multiple View Geometry".</p>
<p>Property of an affine (and projective?) transformation:</p>
<ul>
<li>If the determinant of the top-left 2x2 matrix is > 0 the transformation is orientation-preserving.</li>
<li>Else if the determinant is < 0, it is orientation-reversing.</li>
</ul>
http://answers.opencv.org/question/2588/check-if-homography-is-good/?comment=2602#post-id-2602Hmm thanks a lot! anyway i think we have a 3x3 Matrix as explained by opencv doc
Tue, 25 Sep 2012 09:32:17 -0500http://answers.opencv.org/question/2588/check-if-homography-is-good/?comment=2602#post-id-2602