如何使平面适合 3D 点云? [英] How to fit a plane to a 3D point cloud?

查看:25
本文介绍了如何使平面适合 3D 点云?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将平面拟合到 3D 点云.我使用 RANSAC 方法,我从点云中采样几个点,计算平面,并以最小的误差存储平面.误差是点与平面之间的距离.我想用 C++ 做这个,使用 Eigen.

I want to fit a plane to a 3D point cloud. I use a RANSAC approach, where I sample several points from the point cloud, calculate the plane, and store the plane with the smallest error. The error is the distance between the points and the plane. I want to do this in C++, using Eigen.

到目前为止,我从点云中采样点并将数据居中.现在,我需要将平面拟合到样本点.我知道我需要解决 Mx = 0,但是我该怎么做呢?到目前为止,我有 M(我的样本),我想知道 x(平面)并且这个拟合需要尽可能接近 0.

So far, I sample points from the point cloud and center the data. Now, I need to fit the plane to the samples points. I know I need to solve Mx = 0, but how do I do this? So far I have M (my samples), I want to know x (the plane) and this fit needs to be as close to 0 as possible.

我不知道从哪里开始.我只有我的采样点,我需要更多数据.

I have no idea where to continue from here. All I have are my sampled points and I need more data.

推荐答案

根据你的问题,我假设你熟悉 Ransac 算法,所以我就不多说了.

From you question I assume that you are familiar with the Ransac algorithm, so I will spare you of lengthy talks.

第一步,您对三个随机点进行采样.您可以使用 Random 类,但选择不是真正随机的通常会更好结果.对于这些点,您可以使用 Hyperplane::Through 简单地拟合平面.

In a first step, you sample three random points. You can use the Random class for that but picking them not truly random usually gives better results. To those points, you can simply fit a plane using Hyperplane::Through.

在第二步中,您用大Hyperplane::absDistance 并对剩余的进行最小二乘拟合.它可能看起来像这样:

In the second step, you repetitively cross out some points with large Hyperplane::absDistance and perform a least-squares fit on the remaining ones. It may look like this:

Vector3f mu = mean(points);
Matrix3f covar = covariance(points, mu);
Vector3 normal = smallest_eigenvector(covar);
JacobiSVD<Matrix3f> svd(covariance, ComputeFullU);
Vector3f normal = svd.matrixU().col(2);
Hyperplane<float, 3> result(normal, mu);

不幸的是,函数 meancovariance 不是内置的,但它们编写起来相当简单.

Unfortunately, the functions mean and covariance are not built-in, but they are rather straightforward to code.

这篇关于如何使平面适合 3D 点云?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆