OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Tue, 21 Jan 2014 08:28:49 -0600A question about relation of (K R T H)http://answers.opencv.org/question/26821/a-question-about-relation-of-k-r-t-h/H is homography matrix. R(r1,r2,r3)is a rotation matrix ,t is a translation matrix , k is a intrinsic matrix.I want to get H by R K T,so I use the equation (H = K(R|T).But I want to get the Homography matrix between two 2D images,and I only use r1 r2 just like H = K(r1,r2,T).Is that right?? Thank you for your reply!!Mon, 20 Jan 2014 11:55:01 -0600http://answers.opencv.org/question/26821/a-question-about-relation-of-k-r-t-h/Answer by jensenb for <p>H is homography matrix. R(r1,r2,r3)is a rotation matrix ,t is a translation matrix , k is a intrinsic matrix.I want to get H by R K T,so I use the equation (H = K(R|T).But I want to get the Homography matrix between two 2D images,and I only use r1 r2 just like H = K(r1,r2,T).Is that right?? Thank you for your reply!!</p>
http://answers.opencv.org/question/26821/a-question-about-relation-of-k-r-t-h/?answer=26866#post-id-26866Yes that is a correct assumption. To understand why, recall that a homography is an arbitrary linear mapping between two planes, in your case between a world plane and the image plane. The pinhole camera model specifies the projection of arbitrary 3d world points as
![image description](/upfiles/13902942887875519.gif)
A homography requires that the world points lie on a plane, adding an additional constraint to the projection equation above. Because the absolute position of the camera and plane in world coordinates is not relevant for the projection, only their relative pose to each other (specified by R and t), we can arbitrarily require that the 3d world points lie on the X-Y world plane (Z=0) without any loss of generality. This simplifies the projection equation down to
![image description](/upfiles/13902946866399315.png)
This is the trick used by Zhang as part of his [flexible camera calibration technique](http://research.microsoft.com/en-us/um/people/zhang/calib/) (used by OpenCV) for example.Tue, 21 Jan 2014 03:03:00 -0600http://answers.opencv.org/question/26821/a-question-about-relation-of-k-r-t-h/?answer=26866#post-id-26866Comment by 我干过豪哥 for <p>Yes that is a correct assumption. To understand why, recall that a homography is an arbitrary linear mapping between two planes, in your case between a world plane and the image plane. The pinhole camera model specifies the projection of arbitrary 3d world points as</p>
<p><img alt="image description" src="/upfiles/13902942887875519.gif"></p>
<p>A homography requires that the world points lie on a plane, adding an additional constraint to the projection equation above. Because the absolute position of the camera and plane in world coordinates is not relevant for the projection, only their relative pose to each other (specified by R and t), we can arbitrarily require that the 3d world points lie on the X-Y world plane (Z=0) without any loss of generality. This simplifies the projection equation down to</p>
<p><img alt="image description" src="/upfiles/13902946866399315.png"></p>
<p>This is the trick used by Zhang as part of his <a href="http://research.microsoft.com/en-us/um/people/zhang/calib/">flexible camera calibration technique</a> (used by OpenCV) for example.</p>
http://answers.opencv.org/question/26821/a-question-about-relation-of-k-r-t-h/?comment=26900#post-id-26900I choose pairwise points manually instead of surf features.My purpose is that using Homography matrix to map the pics on the final pano instead of warp the image by K and R.And I have get a good final panorama by stitch moudle order.So I want to know ,is the idea"use homograph matrix to map pic insteadof stitch module" right?Tue, 21 Jan 2014 08:28:49 -0600http://answers.opencv.org/question/26821/a-question-about-relation-of-k-r-t-h/?comment=26900#post-id-26900Comment by jensenb for <p>Yes that is a correct assumption. To understand why, recall that a homography is an arbitrary linear mapping between two planes, in your case between a world plane and the image plane. The pinhole camera model specifies the projection of arbitrary 3d world points as</p>
<p><img alt="image description" src="/upfiles/13902942887875519.gif"></p>
<p>A homography requires that the world points lie on a plane, adding an additional constraint to the projection equation above. Because the absolute position of the camera and plane in world coordinates is not relevant for the projection, only their relative pose to each other (specified by R and t), we can arbitrarily require that the 3d world points lie on the X-Y world plane (Z=0) without any loss of generality. This simplifies the projection equation down to</p>
<p><img alt="image description" src="/upfiles/13902946866399315.png"></p>
<p>This is the trick used by Zhang as part of his <a href="http://research.microsoft.com/en-us/um/people/zhang/calib/">flexible camera calibration technique</a> (used by OpenCV) for example.</p>
http://answers.opencv.org/question/26821/a-question-about-relation-of-k-r-t-h/?comment=26891#post-id-26891I'm not so familiar with the stitching module, so this is just a guess, but the docs say that the rotations and translations are estimated pairwise between the images, so maybe you are applying the Homography between the wrong pairs, or in the wrong order?Tue, 21 Jan 2014 07:14:45 -0600http://answers.opencv.org/question/26821/a-question-about-relation-of-k-r-t-h/?comment=26891#post-id-26891Comment by 我干过豪哥 for <p>Yes that is a correct assumption. To understand why, recall that a homography is an arbitrary linear mapping between two planes, in your case between a world plane and the image plane. The pinhole camera model specifies the projection of arbitrary 3d world points as</p>
<p><img alt="image description" src="/upfiles/13902942887875519.gif"></p>
<p>A homography requires that the world points lie on a plane, adding an additional constraint to the projection equation above. Because the absolute position of the camera and plane in world coordinates is not relevant for the projection, only their relative pose to each other (specified by R and t), we can arbitrarily require that the 3d world points lie on the X-Y world plane (Z=0) without any loss of generality. This simplifies the projection equation down to</p>
<p><img alt="image description" src="/upfiles/13902946866399315.png"></p>
<p>This is the trick used by Zhang as part of his <a href="http://research.microsoft.com/en-us/um/people/zhang/calib/">flexible camera calibration technique</a> (used by OpenCV) for example.</p>
http://answers.opencv.org/question/26821/a-question-about-relation-of-k-r-t-h/?comment=26881#post-id-26881Thanks,Bro! I got Homography matrix like above.But I use the K,R refined Bundleadjuster in opencv stitch module to calculate Homography matrix.For example, I have four pic(P1,P2,P3,P4) to stitch a panorama,so I will calculate four H(H1,H2,H3,H4)correspoding to(P1 to P4),finally I try to use function warpPespective(H)to map Pic to the final pano instead of function remap(K,R)(opencvStitchmodule use remap to map pics to final pano).I tried to realize that idea this afternoon and failed.So I want to know ,is my idea right?Tue, 21 Jan 2014 05:53:52 -0600http://answers.opencv.org/question/26821/a-question-about-relation-of-k-r-t-h/?comment=26881#post-id-26881