OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Sun, 06 Mar 2016 19:21:25 -0600Camera projection matrix from fundamentalhttp://answers.opencv.org/question/89418/camera-projection-matrix-from-fundamental/I'm pretty new to OpenCV and trying to puzzle together a monocular AR application **getting structure from motion**. I've got a tracker up and running which tracks points pretty well as the optical flow looks good. It needs to work on uncalibrated cameras.
From the point correspondences I get the fundamental matrix from findFundamentalMat, but I'm lost at how to get the camera projection matrix. Matrix math is not my strong suit, and for all my google foo all I can find are examples using pre-calibrated cameras.
1. Find fundamental matrix using findFundamentalMat (check!)
2. Find epilines with computeCorrespondEpilines (check!)
3. **Extract projection matrix P and P1** (????)
P is identity matrix for the uncalibrated case, but **how do I get P1**?
Sat, 05 Mar 2016 05:03:55 -0600http://answers.opencv.org/question/89418/camera-projection-matrix-from-fundamental/Comment by Eduardo for <p>I'm pretty new to OpenCV and trying to puzzle together a monocular AR application <strong>getting structure from motion</strong>. I've got a tracker up and running which tracks points pretty well as the optical flow looks good. It needs to work on uncalibrated cameras.</p>
<p>From the point correspondences I get the fundamental matrix from findFundamentalMat, but I'm lost at how to get the camera projection matrix. Matrix math is not my strong suit, and for all my google foo all I can find are examples using pre-calibrated cameras.</p>
<ol>
<li>Find fundamental matrix using findFundamentalMat (check!)</li>
<li>Find epilines with computeCorrespondEpilines (check!)</li>
<li><strong>Extract projection matrix P and P1</strong> (????)</li>
</ol>
<p>P is identity matrix for the uncalibrated case, but <strong>how do I get P1</strong>?</p>
http://answers.opencv.org/question/89418/camera-projection-matrix-from-fundamental/?comment=89529#post-id-89529I think that what you want is:
- P = K [I | 0] with K unknown in your case or ignored
- P1 = K [R | t] with K (two views from the same camera) unknown in your case or ignored
To compute R and t, you can look at the link [Determining R and t from E](https://en.wikipedia.org/wiki/Essential_matrix#Determining_R_and_t_from_E) or directly from the book "Multiple View Geometry in computer vision" from Hartley and Zisserman.
My bad, I thought that what you wanted was the extrinsic matrix or the camera pose but what you want is the camera projection matrix that map a point in 3D in the camera frame to a point in 2d in the image frame.Sun, 06 Mar 2016 19:21:25 -0600http://answers.opencv.org/question/89418/camera-projection-matrix-from-fundamental/?comment=89529#post-id-89529Comment by menneske for <p>I'm pretty new to OpenCV and trying to puzzle together a monocular AR application <strong>getting structure from motion</strong>. I've got a tracker up and running which tracks points pretty well as the optical flow looks good. It needs to work on uncalibrated cameras.</p>
<p>From the point correspondences I get the fundamental matrix from findFundamentalMat, but I'm lost at how to get the camera projection matrix. Matrix math is not my strong suit, and for all my google foo all I can find are examples using pre-calibrated cameras.</p>
<ol>
<li>Find fundamental matrix using findFundamentalMat (check!)</li>
<li>Find epilines with computeCorrespondEpilines (check!)</li>
<li><strong>Extract projection matrix P and P1</strong> (????)</li>
</ol>
<p>P is identity matrix for the uncalibrated case, but <strong>how do I get P1</strong>?</p>
http://answers.opencv.org/question/89418/camera-projection-matrix-from-fundamental/?comment=89489#post-id-89489Hi, thanks for the links I'll look into that. I'm not worried about getting the scale correct, as this is for entertainment not science. The question about getting the P1 is probably trivial, as most texts just say "from the fundamental matrix you can extract P and P1" and then just continue as if P and P1 is now available... I'm fine with only knowing P1s translation and rotation relative to P (where I assume it will be in some arbitrarily chosen scale?)Sun, 06 Mar 2016 08:12:29 -0600http://answers.opencv.org/question/89418/camera-projection-matrix-from-fundamental/?comment=89489#post-id-89489Comment by Eduardo for <p>I'm pretty new to OpenCV and trying to puzzle together a monocular AR application <strong>getting structure from motion</strong>. I've got a tracker up and running which tracks points pretty well as the optical flow looks good. It needs to work on uncalibrated cameras.</p>
<p>From the point correspondences I get the fundamental matrix from findFundamentalMat, but I'm lost at how to get the camera projection matrix. Matrix math is not my strong suit, and for all my google foo all I can find are examples using pre-calibrated cameras.</p>
<ol>
<li>Find fundamental matrix using findFundamentalMat (check!)</li>
<li>Find epilines with computeCorrespondEpilines (check!)</li>
<li><strong>Extract projection matrix P and P1</strong> (????)</li>
</ol>
<p>P is identity matrix for the uncalibrated case, but <strong>how do I get P1</strong>?</p>
http://answers.opencv.org/question/89418/camera-projection-matrix-from-fundamental/?comment=89435#post-id-89435You should start by looking to the corresponding topics, fundamental matrix and essential matrix, for example:
- [Essential and Fundamental Matrices](http://www.cse.psu.edu/~rtc12/CSE486/lecture19.pdf)
- Multiple View Geometry in Computer Vision, there is a free sample chapter: [Epipolar Geometry and the Fundamental Matrix](https://www.robots.ox.ac.uk/~vgg/hzbook/hzbook2/HZepipolar.pdf)
- [The Fundamental matrix: theory, algorithms, and stability analysis](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.31.761&rep=rep1&type=pdf)
You just have to grab the idea behind the theory and get the geometry idea.Sat, 05 Mar 2016 11:32:27 -0600http://answers.opencv.org/question/89418/camera-projection-matrix-from-fundamental/?comment=89435#post-id-89435Comment by Eduardo for <p>I'm pretty new to OpenCV and trying to puzzle together a monocular AR application <strong>getting structure from motion</strong>. I've got a tracker up and running which tracks points pretty well as the optical flow looks good. It needs to work on uncalibrated cameras.</p>
<p>From the point correspondences I get the fundamental matrix from findFundamentalMat, but I'm lost at how to get the camera projection matrix. Matrix math is not my strong suit, and for all my google foo all I can find are examples using pre-calibrated cameras.</p>
<ol>
<li>Find fundamental matrix using findFundamentalMat (check!)</li>
<li>Find epilines with computeCorrespondEpilines (check!)</li>
<li><strong>Extract projection matrix P and P1</strong> (????)</li>
</ol>
<p>P is identity matrix for the uncalibrated case, but <strong>how do I get P1</strong>?</p>
http://answers.opencv.org/question/89418/camera-projection-matrix-from-fundamental/?comment=89437#post-id-89437In my opinion, get the projection matrix (the intrinsic + extrinsic parameters) is not possible.
Why, because intuitively given two views from uncalibrated and at unknown position cameras, you can estimate the camera motion that transforms one set of points to another set of points but you cannot get the 3D information as the pinhole camera model "suppress" this information.
Even with calibrated cameras, it seems that you can only [estimate](https://en.wikipedia.org/wiki/Essential_matrix#Determining_R_and_t_from_E) the rotation and translation (up to a scale) from one camera to the other camera but if the inital pose of the first camera is unknow, it seems that you cannot get the full projection matrix for me.
But don't take my word for it, that's why I posted the different links.Sat, 05 Mar 2016 11:44:27 -0600http://answers.opencv.org/question/89418/camera-projection-matrix-from-fundamental/?comment=89437#post-id-89437