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 07:47:48 -0500good result or bad result for findHomographyhttp://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/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?Thu, 02 Aug 2012 12:13:47 -0500http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/Comment by ZettaCircl for <p>I read that for finding that the homography is good or bad thare are 2 solution:</p>
<ol>
<li><p>Compute the determinant of the homography, and see if it's too close to zero for comfort.</p></li>
<li><p>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.</p></li>
</ol>
<p>Is this true? and there is a method to calculate the SVD in opencv?</p>
http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?comment=212018#post-id-212018He read it there : https://stackoverflow.com/questions/10972438/detecting-garbage-homographies-from-findhomography-in-opencv/10981249#10981249Tue, 23 Apr 2019 07:46:03 -0500http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?comment=212018#post-id-212018Comment by MariGeek for <p>I read that for finding that the homography is good or bad thare are 2 solution:</p>
<ol>
<li><p>Compute the determinant of the homography, and see if it's too close to zero for comfort.</p></li>
<li><p>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.</p></li>
</ol>
<p>Is this true? and there is a method to calculate the SVD in opencv?</p>
http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?comment=181425#post-id-181425What do you mean by first-to-last ? and also can you give reference where you read it?
thanksMon, 01 Jan 2018 03:19:02 -0600http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?comment=181425#post-id-181425Answer by dma for <p>I read that for finding that the homography is good or bad thare are 2 solution:</p>
<ol>
<li><p>Compute the determinant of the homography, and see if it's too close to zero for comfort.</p></li>
<li><p>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.</p></li>
</ol>
<p>Is this true? and there is a method to calculate the SVD in opencv?</p>
http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?answer=25383#post-id-25383My 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]
*/
Thu, 12 Dec 2013 17:44:14 -0600http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?answer=25383#post-id-25383Comment by ZettaCircl for <p>My understanding concerning :</p>
<ol>
<li>"Compute the determinant of the homography, and see if it's too close to zero for comfort."</li>
</ol>
<p>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).</p>
<p>const double det = H.at<double>(0, 0) * H.at<double>(1, 1) - H.at<double>(1, 0) * H.at<double>(0, 1);</p>
<p>One way to do it would be to specify a positive value, higher than 1, say N, and then:</p>
<p>if((fabs(det)>(double)N) || (fabs(det)<(1.0/(double)N)) return false; // bad homography</p>
<p>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).</p>
<p>if(det<0) return false; // no mirrors in the scene </p>
<p>/* 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]
*/</p>
http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?comment=212019#post-id-212019It's a threshold, it's written.Tue, 23 Apr 2019 07:47:48 -0500http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?comment=212019#post-id-212019Comment by MariGeek for <p>My understanding concerning :</p>
<ol>
<li>"Compute the determinant of the homography, and see if it's too close to zero for comfort."</li>
</ol>
<p>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).</p>
<p>const double det = H.at<double>(0, 0) * H.at<double>(1, 1) - H.at<double>(1, 0) * H.at<double>(0, 1);</p>
<p>One way to do it would be to specify a positive value, higher than 1, say N, and then:</p>
<p>if((fabs(det)>(double)N) || (fabs(det)<(1.0/(double)N)) return false; // bad homography</p>
<p>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).</p>
<p>if(det<0) return false; // no mirrors in the scene </p>
<p>/* 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]
*/</p>
http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?comment=181424#post-id-181424What is N here?Mon, 01 Jan 2018 03:04:26 -0600http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?comment=181424#post-id-181424Comment by MariGeek for <p>My understanding concerning :</p>
<ol>
<li>"Compute the determinant of the homography, and see if it's too close to zero for comfort."</li>
</ol>
<p>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).</p>
<p>const double det = H.at<double>(0, 0) * H.at<double>(1, 1) - H.at<double>(1, 0) * H.at<double>(0, 1);</p>
<p>One way to do it would be to specify a positive value, higher than 1, say N, and then:</p>
<p>if((fabs(det)>(double)N) || (fabs(det)<(1.0/(double)N)) return false; // bad homography</p>
<p>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).</p>
<p>if(det<0) return false; // no mirrors in the scene </p>
<p>/* 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]
*/</p>
http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?comment=181423#post-id-181423thank you for clear answer with reference.Mon, 01 Jan 2018 01:05:04 -0600http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?comment=181423#post-id-181423Answer by niccer for <p>I read that for finding that the homography is good or bad thare are 2 solution:</p>
<ol>
<li><p>Compute the determinant of the homography, and see if it's too close to zero for comfort.</p></li>
<li><p>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.</p></li>
</ol>
<p>Is this true? and there is a method to calculate the SVD in opencv?</p>
http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?answer=181757#post-id-181757To 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.Fri, 05 Jan 2018 09:02:42 -0600http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?answer=181757#post-id-181757Answer by Adi for <p>I read that for finding that the homography is good or bad thare are 2 solution:</p>
<ol>
<li><p>Compute the determinant of the homography, and see if it's too close to zero for comfort.</p></li>
<li><p>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.</p></li>
</ol>
<p>Is this true? and there is a method to calculate the SVD in opencv?</p>
http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?answer=1094#post-id-1094Algebraically, 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](http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#svd).Thu, 02 Aug 2012 13:12:33 -0500http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?answer=1094#post-id-1094Comment by Dirhem for <p>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. </p>
<p>OpenCV <a href="http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#svd">supports SVD</a>.</p>
http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?comment=13056#post-id-13056How can i compute SVD and and verify that the ratio of the first-to-last singular value is sane with OpenCV? Tue, 07 May 2013 17:04:36 -0500http://answers.opencv.org/question/1090/good-result-or-bad-result-for-findhomography/?comment=13056#post-id-13056