OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Tue, 26 Jul 2016 20:35:17 -0500OpenCV Structure from Motion Reprojection Issuehttp://answers.opencv.org/question/98966/opencv-structure-from-motion-reprojection-issue/ I am currently facing an issue with my Structure from Motion program based on OpenCv. I'm gonna try to depict you what it does, and what it is supposed to do.
This program lies on the classic "structure from motion" method.
The basic idea is to take a pair of images, detect their keypoints and compute the descriptors of those keypoints. Then, the keypoints matching is done, with a certain number of tests to insure the result is good. That part works perfectly.
Once this is done, the following computations are performed : fundamental matrix, essential matrix, SVD decomposition of the essential matrix, camera matrix computation and finally, triangulation.
The result for a pair of images is a set of 3D coordinates, giving us points to be drawn in a 3D viewer. This works perfectly, for a pair.
Indeed, here is my problem : for a pair of images, the 3D points coordinates are calculated in the coordinate system of the first image of the image pair, taken as the reference image. When working with more than two images, which is the objective of my program, I have to reproject the 3D points computed in the coordinate system of the very first image, in order to get a consistent result.
My question is : How do I reproject 3D points coordinate given in a camera related system, into an other camera related system ? With the camera matrices ?
My idea was to take the 3D point coordinates, and to multiply them by the inverse of each camera matrix before.
I clarify :
Suppose I am working on the third and fourth image (hence, the third pair of images, because I am working like 1-2 / 2-3 / 3-4 and so on).
I get my 3D point coordinates in the coordinate system of the third image, how do I do to reproject them properly in the very first image coordinate system ?
I would have done the following :
Get the 3D points coordinates matrix, apply the inverse of the camera matrix for image 2 to 3, and then apply the inverse of the camera matrix for image 1 to 2. Is that even correct ?
Because those camera matrices are non square matrices, and I can't inverse them.
I am surely mistaking somewhere, and I would be grateful if someone could enlighten me, I am pretty sure this is a relative easy one, but I am obviously missing something...
Thanks a lot for reading :)Tue, 26 Jul 2016 03:07:17 -0500http://answers.opencv.org/question/98966/opencv-structure-from-motion-reprojection-issue/Comment by Tetragramm for <p>I am currently facing an issue with my Structure from Motion program based on OpenCv. I'm gonna try to depict you what it does, and what it is supposed to do.</p>
<p>This program lies on the classic "structure from motion" method.</p>
<p>The basic idea is to take a pair of images, detect their keypoints and compute the descriptors of those keypoints. Then, the keypoints matching is done, with a certain number of tests to insure the result is good. That part works perfectly.</p>
<p>Once this is done, the following computations are performed : fundamental matrix, essential matrix, SVD decomposition of the essential matrix, camera matrix computation and finally, triangulation.</p>
<p>The result for a pair of images is a set of 3D coordinates, giving us points to be drawn in a 3D viewer. This works perfectly, for a pair.</p>
<p>Indeed, here is my problem : for a pair of images, the 3D points coordinates are calculated in the coordinate system of the first image of the image pair, taken as the reference image. When working with more than two images, which is the objective of my program, I have to reproject the 3D points computed in the coordinate system of the very first image, in order to get a consistent result.</p>
<p>My question is : How do I reproject 3D points coordinate given in a camera related system, into an other camera related system ? With the camera matrices ?</p>
<p>My idea was to take the 3D point coordinates, and to multiply them by the inverse of each camera matrix before.</p>
<p>I clarify :</p>
<p>Suppose I am working on the third and fourth image (hence, the third pair of images, because I am working like 1-2 / 2-3 / 3-4 and so on).</p>
<p>I get my 3D point coordinates in the coordinate system of the third image, how do I do to reproject them properly in the very first image coordinate system ?</p>
<p>I would have done the following :</p>
<p>Get the 3D points coordinates matrix, apply the inverse of the camera matrix for image 2 to 3, and then apply the inverse of the camera matrix for image 1 to 2. Is that even correct ?</p>
<p>Because those camera matrices are non square matrices, and I can't inverse them.</p>
<p>I am surely mistaking somewhere, and I would be grateful if someone could enlighten me, I am pretty sure this is a relative easy one, but I am obviously missing something...</p>
<p>Thanks a lot for reading :)</p>
http://answers.opencv.org/question/98966/opencv-structure-from-motion-reprojection-issue/?comment=99028#post-id-99028To follow on that, the function [recoverPose](http://docs.opencv.org/3.1.0/d9/d0c/group__calib3d.html#gadb7d2dfcc184c1d2f496d8639f4371c0) can go from 2D points and the essential matrix to relative rotation and translation.Tue, 26 Jul 2016 20:35:17 -0500http://answers.opencv.org/question/98966/opencv-structure-from-motion-reprojection-issue/?comment=99028#post-id-99028Comment by Eduardo for <p>I am currently facing an issue with my Structure from Motion program based on OpenCv. I'm gonna try to depict you what it does, and what it is supposed to do.</p>
<p>This program lies on the classic "structure from motion" method.</p>
<p>The basic idea is to take a pair of images, detect their keypoints and compute the descriptors of those keypoints. Then, the keypoints matching is done, with a certain number of tests to insure the result is good. That part works perfectly.</p>
<p>Once this is done, the following computations are performed : fundamental matrix, essential matrix, SVD decomposition of the essential matrix, camera matrix computation and finally, triangulation.</p>
<p>The result for a pair of images is a set of 3D coordinates, giving us points to be drawn in a 3D viewer. This works perfectly, for a pair.</p>
<p>Indeed, here is my problem : for a pair of images, the 3D points coordinates are calculated in the coordinate system of the first image of the image pair, taken as the reference image. When working with more than two images, which is the objective of my program, I have to reproject the 3D points computed in the coordinate system of the very first image, in order to get a consistent result.</p>
<p>My question is : How do I reproject 3D points coordinate given in a camera related system, into an other camera related system ? With the camera matrices ?</p>
<p>My idea was to take the 3D point coordinates, and to multiply them by the inverse of each camera matrix before.</p>
<p>I clarify :</p>
<p>Suppose I am working on the third and fourth image (hence, the third pair of images, because I am working like 1-2 / 2-3 / 3-4 and so on).</p>
<p>I get my 3D point coordinates in the coordinate system of the third image, how do I do to reproject them properly in the very first image coordinate system ?</p>
<p>I would have done the following :</p>
<p>Get the 3D points coordinates matrix, apply the inverse of the camera matrix for image 2 to 3, and then apply the inverse of the camera matrix for image 1 to 2. Is that even correct ?</p>
<p>Because those camera matrices are non square matrices, and I can't inverse them.</p>
<p>I am surely mistaking somewhere, and I would be grateful if someone could enlighten me, I am pretty sure this is a relative easy one, but I am obviously missing something...</p>
<p>Thanks a lot for reading :)</p>
http://answers.opencv.org/question/98966/opencv-structure-from-motion-reprojection-issue/?comment=99000#post-id-99000Quick answer: if you want to reproject a 3D point into another coordinate frame, you need the corresponding transformation matrix (rotation + translation) between the two frames. You can search for homogeneous transformation matrix for that.
These information can be known if you use for example a rigid camera system after some calibration step. In the structure from motion case, you have the essential matrix but as this is not my field I don't know what you can get with the fundamental / essential matrices.Tue, 26 Jul 2016 08:36:36 -0500http://answers.opencv.org/question/98966/opencv-structure-from-motion-reprojection-issue/?comment=99000#post-id-99000