### Integrate RANSAC to compute essential matrix

**159** 观看

**1**回复

**487**
作者的声誉

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 日### 回应 (1)

**1**像

**2149**
作者的声誉

**决定**

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###### 来自类别的问题 :

- computer-vision 图像比较-快速算法
- computer-vision 查找区域遮罩代表的多边形的角
- computer-vision 在Flash中是否有用于查找人眼和嘴巴的快速库？（由ActionScript）
- computer-vision 在iPhone上使用OpenGL ES卷积图像：可能吗？
- computer-vision 关于使用卡尔曼滤波器跟踪移动球的问题
- computer-vision 通过OpenCV的camshift算法控制鼠标指针（或鼠标的基本功能）
- computer-vision 跨多个图像的相机校准
- computer-vision 什么是*绘制* std :: vector <double>的简单/最简单的方法？
- computer-vision 从霍夫变换中提取线段
- computer-vision 将两个图像与OpenCV结合使用
- computer-vision 将OpenCV图像转换为黑白图像
- computer-vision cvCreateCameraCapture不起作用
- computer-vision OpenCV C ++ / Obj-C：检测一张纸/方形检测
- computer-vision 精确肤色HSV系列
- computer-vision 如何在Android增强现实中检测物理对象？
- computer-vision 如何使用MATLAB从视频中消除由于相机抖动造成的影响？
- computer-vision 通过在纸上处理二维草图生成三维对象
- computer-vision 从视频中提取关键帧
- computer-vision Python边缘检测和曲率计算
- computer-vision 使用Opencv分布良好的功能