Note that there are some explanatory texts on larger screens.

plurals
  1. POCalculating camera motion out of corresponding 3d point sets
    text
    copied!<p>I am having a little problem. I wrote a program that extracts a set of three-dimensional points in each frame using a camera and depth information. The points are in the <strong>camera coordinate system</strong>, which means the origin is at the camera center, x is horizontal distance, y vertical distance and z the distance from the camera (along the optical axis). Everything is in meters. I.e. point (2,-1,5) would be two meters right, one meter below and five meters along the optical axis of the camera.</p> <p>I calculate these points in each time frame and also know the correspondences, like I know which point in <code>t-1</code> belongs to which 3d point in <code>t</code>.</p> <p>My goal now is to calculate the motion of the camera in each time frame in my world coordinate system (with z pointing up representing the height). I would like to calculate relative motion but also the absolute one starting from some start position to visualize the trajectory of the camera.</p> <hr> <p>This is an example data set of one frame with the current (left) and the previous 3D location (right) of the points in camera coordinates:</p> <pre><code>-0.174004 0.242901 3.672510 | -0.089167 0.246231 3.646694 -0.265066 -0.079420 3.668801 | -0.182261 -0.075341 3.634996 0.092708 0.459499 3.673029 | 0.179553 0.459284 3.636645 0.593070 0.056592 3.542869 | 0.675082 0.051625 3.509424 0.676054 0.517077 3.585216 | 0.763378 0.511976 3.555986 0.555625 -0.350790 3.496224 | 0.633524 -0.354710 3.465260 1.189281 0.953641 3.556284 | 1.274754 0.938846 3.504309 0.489797 -0.933973 3.435228 | 0.561585 -0.935864 3.404614 </code></pre> <hr> <p>Since I would like to work with OpenCV if possible I found the <code>estimateAffine3D()</code> function in OpenCV 2.3, which takes two 3D point input vectors and calculates the affine transformation between them using RANSAC.</p> <p>As output I get a 3x4 transformation matrix.</p> <p>I already tried to make the calculation more accurate by setting the RANSAC parameters but a lot of times the trnasformation matrix shows a translatory movement that is quite big. As you can see in the sample data the movement is usually quite small.</p> <p>So I wanted to ask if anybody has another idea on what I could try? Does OpenCV offer other solutions for this?</p> <p>Also if I have the relative motion of the camera in each timeframe, how would I convert it to world coordinates? Also how would I then get the absolute position starting from a point (0,0,0) so I have the camera position (and direction) for each time frame?</p> <p>Would be great if anybody could give me some advice!</p> <p>Thank you!</p> <p><strong>UPDATE 1:</strong></p> <p>After @Michael Kupchick nice answer I tried to check how well the estimateAffine3D() function in OpenCV works. So I created two little test sets of 6 point-pairs that just have a translation, not a rotation and had a look at the resulting transformation matrix:</p> <p><em><strong>Test set 1:</em></strong></p> <pre><code>1.5 2.1 6.7 | 0.5 1.1 5.7 6.7 4.5 12.4 | 5.7 3.5 11.4 3.5 3.2 1.2 | 2.5 2.2 0.2 -10.2 5.5 5.5 | -11.2 4.5 4.5 -7.2 -2.2 6.5 | -8.2 -3.2 5.5 -2.2 -7.3 19.2 | -3.2 -8.3 18.2 </code></pre> <p>Transformation Matrix:</p> <pre><code>1 -1.0573e-16 -6.4096e-17 1 -1.3633e-16 1 2.59504e-16 1 3.20342e-09 1.14395e-09 1 1 </code></pre> <p><em><strong>Test set 2:</em></strong></p> <pre><code>1.5 2.1 0 | 0.5 1.1 0 6.7 4.5 0 | 5.7 3.5 0 3.5 3.2 0 | 2.5 2.2 0 -10.2 5.5 0 | -11.2 4.5 0 -7.2 -2.2 0 | -8.2 -3.2 0 -2.2 -7.3 0 | -3.2 -8.3 0 </code></pre> <p>Transformation Matrix:</p> <pre><code>1 4.4442e-17 0 1 -2.69695e-17 1 0 1 0 0 0 0 </code></pre> <p>--> This gives me two transformation matrices that look right at first sight...</p> <p>Assuming this is right, how would I recalculate the trajectory of this when I have this transformation matrix in each timestep?</p> <p>Anybody any tips or ideas why it's that bad?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload