c++ - PCL 的主成分分析

标签 c++ cluster-analysis pca point-cloud-library point-clouds

我正在将 PCL 与 C++ 结合使用,并希望在已经聚类的点云(即每个单独的聚类)上执行 PCA。这个想法是通过沿着特征向量测量它们的大小来消除所有太大/太小的簇。所以预期的算法是:获取每个集群的特征向量,将集群点投影到相应的特征向量上,以测量点沿这些维度的最大距离,并从那里消除所有具有“坏”维度/维度比率的集群。我在实现时遇到困难。您能提供的帮助越多,您就越开心。这就是我的数据的组织方式(为了清楚起见,这些是片段,cluster_indices 已经被正确提取并经过检查),以及我开始的内容:

std::vector<pcl::PointIndices> cluster_indices;
pcl::PCA<pcl::PointXYZ> cpca = new pcl::PCA<pcl::PointXYZ>;
cpca.setInputCloud(input);
Eigen::Vector3f pca_vector(3,3);
// and now iterating with a for loop over the clusters, but having issues using setIndices already
for (std::vector<pcl::PointIndices>::const_iterator it = cluster_indices.begin (); it != cluster_indices.end (); ++it, n++)
{
    cpca.setIndices(it->indices); //not sure what to put in brackets, everything I thought of returns an error!
    pca_vector = cpca.getEigenVectors();
}

最佳答案

这似乎是一个普遍的问题。所以我找到了这个解决方案: 不要使用指针进行迭代,而是使用常规迭代器,然后使用这些公式。 PointIndicesPtr pi_ptr(new PointIndices); pi_ptr->indices = cluster_indices[i].indices; //现在可以使用pi_ptr作为输入

关于c++ - PCL 的主成分分析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37905260/

相关文章:

c++ - 为什么即使内容发生变化,字符串变量的 sizeof() 也总是返回相同的数字?

python - scikit-learn 中的 DBSCAN(仅限指标)

r - ggbiplot - 更改标签的颜色

python - 为 PCA 准备图像数据

r - 在主成分分析(PCA)图中添加椭圆

c++ - 我的 C++ 内联方法是否应该显式声明为内联?

c++ - 无法通过 C++ 中的隐式转换找到运算符

c++ - 我如何将 system_clock::now() 与 c++20 中的本地时间进行比较?

machine-learning - K表示多维数据的聚类

python-3.x - 矩形聚类