OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Sat, 05 Aug 2017 09:08:22 -0500Projection matrices in OpenCV vs Multiple View Geometryhttp://answers.opencv.org/question/170947/projection-matrices-in-opencv-vs-multiple-view-geometry/ I am trying to follow "Multiple View Geometry in Computer Vision" formula 13.2 for computing the homography between for a calibrated stereo rig. It should be simple math
H = K' (R - t. transpose(n) / d) inv(K)
Where H is the 3x3 homography. K and K' are 3x3 camera intrinsic matrices, R is a 3x3 rotation between the cameras. t is column vector translation between the cameras. n is a plane normal vector and d is the constant of the plane equation of a plane that both cameras are viewing. The idea here is that going right to left, a homogenous pixel coordinate is unprojected to a ray, the ray is intersected with a plane and the intersection point is projected to the other image.
When I plug numbers in and try to match up two captured images I can't get the math as shown to work. My main problem is that I don't understand how simply multiplying a 3D point by a camera matrix K can project the point. In the opencv documentation for the calibration module:
x' = x / z<p>
y' = y / z<p>
u = fx * x' + cx<p>
v = fy * y' + cy<p>
By the above math, x and y are divided by z before the focal length is multiplied. But I don't see how the math from the text accomplishes the same thing by merely multiplying a point by K. Where is the divide by z in the formula for H?
Can someone help with this problem that is probably just notation?
Scott
Fri, 04 Aug 2017 11:17:47 -0500http://answers.opencv.org/question/170947/projection-matrices-in-opencv-vs-multiple-view-geometry/Answer by Eduardo for <p>I am trying to follow "Multiple View Geometry in Computer Vision" formula 13.2 for computing the homography between for a calibrated stereo rig. It should be simple math </p>
<p>H = K' (R - t. transpose(n) / d) inv(K) </p>
<p>Where H is the 3x3 homography. K and K' are 3x3 camera intrinsic matrices, R is a 3x3 rotation between the cameras. t is column vector translation between the cameras. n is a plane normal vector and d is the constant of the plane equation of a plane that both cameras are viewing. The idea here is that going right to left, a homogenous pixel coordinate is unprojected to a ray, the ray is intersected with a plane and the intersection point is projected to the other image.</p>
<p>When I plug numbers in and try to match up two captured images I can't get the math as shown to work. My main problem is that I don't understand how simply multiplying a 3D point by a camera matrix K can project the point. In the opencv documentation for the calibration module:</p>
<p>x' = x / z</p><p>
y' = y / z</p><p>
u = fx * x' + cx</p><p>
v = fy * y' + cy</p><p></p>
<p>By the above math, x and y are divided by z before the focal length is multiplied. But I don't see how the math from the text accomplishes the same thing by merely multiplying a point by K. Where is the divide by z in the formula for H? </p>
<p>Can someone help with this problem that is probably just notation?
Scott</p>
http://answers.opencv.org/question/170947/projection-matrices-in-opencv-vs-multiple-view-geometry/?answer=171005#post-id-171005See this course: [Lecture 12: Camera Projection, Robert Collins, CSE486, Penn State](http://www.cse.psu.edu/~rtc12/CSE486/lecture12.pdf).
Here the relevant slides uploaded:
![1](/upfiles/1501941653613041.png)
![2](/upfiles/15019416623131336.png)
![3](/upfiles/15019416694938205.png)
Note: here the principal point is not considered (in this representation) but it is the same thing.
Another good [reference](http://www.scratchapixel.com/lessons/3d-basic-rendering/perspective-and-orthographic-projection-matrix/building-basic-perspective-projection-matrix) but more oriented graphics rendering than computer vision.
Sat, 05 Aug 2017 09:08:22 -0500http://answers.opencv.org/question/170947/projection-matrices-in-opencv-vs-multiple-view-geometry/?answer=171005#post-id-171005