Integrate RANSAC to compute essential matrix
I have calculated the essential matrix using the 5 point algorithm. I'm not sure how to integrate it with ransac so it gives me a better outcome.
Here is the source code. https://github.com/lunzhang/openar/blob/master/src/utils/5point/computeEssential.js
Currently, I was thinking about computing the essential matrix for 5 random points then convert the essential matrix to fundamental and see the error threshold using this equation x'Fx = 0. But then I'm not sure, what to do after.
How do I know which points to set as outliners? If the errors too big, do I set them as outliners right away? Could it be possible that one point could produce different essential matrices depending on what the other 4 points are?作者: Lun Zhang 的来源 发布者: 2017 年 12 月 27 日
Well, here is a short explanation, in pseudo-code, of how you can integrate this with ransac. Basically, all Ransac does is compute your model (here the Essential) using a subset of the data, and then sees if the rest of data "is happy" with that result. It keeps the result for which a highest portion of the dataset "is happy".
highest_number_of_happy_points=-1; best_estimated_essential_matrix=Identity; for iter=1 to max_iter_number: n_pts=get_n_random_pts(P);//get a subset of n points from the set of points P. You can use 5, but you can also use more. E=compute_essential(n_pts); number_of_happy_points=0; for pt in P: //we want to know if pt is happy with the computed E err=cost_function(pt,E);//for example x^TFx as you propose, or X^TEX with the essential. if(err<some_threshold): number_of_happy_points+=1; if(number_of_happy_points>highest_number_of_happy_points): highest_number_of_happy_points=number_of_happy_points; best_estimated_essential_matrix=E;
This should do the trick. Usually, you set
some_threshold experimentally to a low value. There are of course more sophisticated Ransacs, you can easily find them by googling.
Your idea of using
x^TFx is fine in my opinion.
Once this Ransac completes, you will have
best_estimated_essential_matrix. The outliers are those that have a
x^TFx value that is greater than your optional threshold.
To answer your final question, yes, a point could produce a different matrix given 4 different points, because their spatial configuration is different (you can have degenerate situations). In an ideal settings this wouldn't be the case, but we always have noise, matching errors and so on, so what happens in the end is that the equations you obtain with 5 points wont produce the exact same results as for 5 other points.
Hope this helps.作者: Ash 发布者: 27.12.2017 08:43