gpt4 book ai didi

c++ - PCL 的主成分分析

转载 作者:太空宇宙 更新时间:2023-11-04 13:14:42 24 4
gpt4 key购买 nike

我正在将 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com