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

问题描述

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

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

我不知道从哪里继续.我所拥有的只是我的采样点,我需要更多数据.

解决方案

从您的问题开始,我假设您熟悉Ransac算法,所以我将避免冗长的讨论.

第一步,对三个随机点进行采样.为此,您可以使用 Random 类,但通常选择不是真正随机的类会更好结果.对于这些问题,您只需使用 Hyperplane :: Through 即可. /p>

在第二步中,您重复地用大的 Hyperplane :: absDistance ,然后对其余的最小二乘拟合.可能看起来像这样:

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不是内置的,但是它们很容易编写代码.

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.

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.

解决方案

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

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.

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);

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

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

06-30 03:18