Re: 5 point algorithm in libmv

190 views
Skip to first unread message

Pau Gargallo

unread,
May 18, 2012, 4:58:27 AM5/18/12
to Henning Tjaden, libmv...@googlegroups.com
Hi Henning,

I wrote this code long ago and don't remember all the details. I'm
copying the mail to the libmv list in case someone can also help. In
any case, here are the answer to your questions:


> - Is the libmv five point implementation ready for use?

It's never been extensively tested with real data, but yes, it should
be ready to use.


> - I get up to 10 solutions for the essential matrix
> from FivePointsRelativePose(). How do I know which E is the right one (I
> could not find that in that in the Stewénius paper either)?

It is normal to get up to 10 solutions. Only one of them will be
correct, but you can not know which one it is with only 5
correspondences. The stardard way to use this functions is inside a
RANSAC loop. That is you iterate the following algo:

1- you sample 5 correspondences out of a large bag of correspondences
2- you compute up to 10 candidate essential matrices using these
correspondences
3- for each candidate, you count the number of inlier correspondeces
in the bag of correspondences
4- you keep the essential matrix with more correspondences.

There is a robust estimation framework in libmv. I remember it being a
bit too bureaucratic, but it works.


> - The values of the resulting translation vector of
> MotionFromEssentialAndCorrespondence() are not what i expected (for all Es I
> get). The values always seem to be between [-1; 1] and the z-component is
> mostly somewhere close to 1.0 regardless of camera movement (I don't even
> see a significant difference when the camera isn't moving at all).

MotionFromEssential assumes that the camera did move. It won't work
for static cameras. Additionally, it is impossible to know how far a
camera did move because there is always a scale ambiguity when
reconstructing things from images. Therefore, MotionFromEssntial
assumes always a translation of length 1. The only unknow is the
direction of the translation not the magnitude.


> Are the
> parameters x1 and x2 the projected coordinates of one matching feature in
> the camera coordinate system (x' = K^-1*x)?

yes, the five point algorithm works with the so called normalized
image coordinates.


> - In the file five_point_test.cc x1 and x2 are set to the following:
>
>> x1Col << d.x[0].col(i)(0), d.x[0].col((i+1) % num_views)(1);
>> x2Col << d.x[1].col(i)(0), d.x[1].col((i+1) % num_views)(1);
>
> Are these lines correct? Just for my better understanding, shouldn't it be:
>
>> x1Col << d.x[i].col(0)(0), d.x[i].col(0)(1);
>> x2Col << d.x[(i+1) % num_views ].col(0)(0), d.x[ (i+1) %
>> num_views ].col(0)(1);

you are right. The code is wrong and there seems to be many more
errors in the rest of the test because it is passing. :O


> I would already like to thank you and your partners for ever writing libmv
> and hope these are not too many or stupid questions.

It's been close to 3 years since i've last done anything for libmv. I
don't know what is its current state, but I'm sure that motivated
coders like you would be a great help! ;-)

Have fun!
pau

Pierre Moulon

unread,
May 18, 2012, 5:12:15 AM5/18/12
to libmv...@googlegroups.com
Hi,

I'm using the code in the ransac of libmv and it works fine.
You have just to use the defined kernel in the Estimate function.

 typedef essential::kernel::FivePointKernel KernelType;
    KernelType kernel(x0, x1, K, K);
    Mat3 EssentialMatrix = Estimate(kernel,
      MLEScorer<KernelType>(Square(YourThreshold))));

You'are right for the error in the five_point_text.cc.
Well see !
Fix it and pull it as a request to the github libmv project.

The test passed because the rotation and translation between the various views is constant. The camera are placed along a ring !

We get back the corresponding point between view 0 and 1 of the NViewDataset.



2012/5/18 Pau Gargallo <pau.ga...@gmail.com>



--
Regards/Cordialement,
Pierre M

Pierre Moulon

unread,
May 18, 2012, 5:23:45 AM5/18/12
to libmv...@googlegroups.com
Hi again,

Your code fix could be simplified
Your solution:

x1Col << d.x[i].col(0)(0), d.x[i].col(0)(1);
x2Col << d.x[(i+1) % num_views ].col(0)(0), d.x[ (i+1) % num_views ].col(0)(1);

Could be simplified in : 
x1Col << d.x[i].col(0)
x2Col << d.x[(i+1) % num_views ].col(0);

Regards,
Pierre

2012/5/18 Pierre Moulon <pmo...@gmail.com>



--
Regards/Cordialement,
Pierre M

Pau Gargallo

unread,
May 18, 2012, 5:48:11 AM5/18/12
to libmv...@googlegroups.com
Hi Pierre,

would you know how to fix the rest of the test. It is weird that there
was such an error and the test is still passing. Otherwise, I would
suggest removing the whole test.

Thanks!
pau

Pau Gargallo

unread,
May 18, 2012, 5:49:30 AM5/18/12
to libmv...@googlegroups.com
Pierre,
didn't read your first mail. Disregard my question ;-)
pau
Reply all
Reply to author
Forward
0 new messages