Open XuankeShi opened 5 years ago
i've try enclideadClusterExtraction for fpfh for each point, but it did't work,is there anyone who has tried it ,i need your help. thx very much.
The code is as follows:
double
computeCloudResolution(const pcl::PointCloud
for (size_t i = 0; i < cloud->size(); ++i)
{
if (!pcl_isfinite((*cloud)[i].x))
continue;
// Considering the second neighbor since the first is the point itself.
nres = tree.nearestKSearch(i, 2, indices, squaredDistances);
if (nres == 2)
{
resolution += sqrt(squaredDistances[1]);
++numberOfPoints;
}
}
if (numberOfPoints != 0)
resolution /= numberOfPoints;
return resolution;
}
int main(int argc, char *argv)
{
pcl::PointCloud
double resolution = 2*computeCloudResolution(scene);
pcl::VoxelGrid<pcl::PointXYZ> vg;
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZ>);
vg.setInputCloud(scene);
vg.setLeafSize(resolution, resolution, resolution);
vg.filter(*cloud_filtered);
std::cout << "PointCloud after filtering has: " << cloud_filtered->points.size() << " data points." << std::endl;
pcl::search::KdTree<pcl::PointXYZ>::Ptr kdtree(new pcl::search::KdTree<pcl::PointXYZ>());
kdtree->setInputCloud(cloud_filtered);
pcl::NormalEstimationOMP<pcl::PointXYZ, pcl::Normal> ne;
ne.setNumberOfThreads(3);
ne.setInputCloud(cloud_filtered);
ne.setSearchMethod(kdtree);
ne.setRadiusSearch(5 * resolution);
ne.setViewPoint(0,0,0);
ne.compute(*normals);
pcl::FPFHEstimation<pcl::PointXYZ, pcl::Normal, pcl::FPFHSignature33> fpfh;
fpfh.setInputCloud(cloud_filtered);
fpfh.setInputNormals(normals);
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>());
fpfh.setSearchMethod(tree);
fpfh.compute(*fpfhs);
//std::vector<pcl::PointIndices> cluster_indices;
std::vector<pcl::PointIndices> cluster_indices;
pcl::EuclideanClusterExtraction<pcl::FPFHSignature33> ec;
ec.setClusterTolerance(10000);
ec.setMinClusterSize(50);
ec.setMaxClusterSize(200000);
pcl::search::KdTree<pcl::FPFHSignature33>::Ptr kdtree2(new pcl::search::KdTree<pcl::FPFHSignature33>);
kdtree2->setInputCloud(fpfhs);
ec.setSearchMethod(kdtree2);
ec.setInputCloud(fpfhs);
ec.extract(cluster_indices);
}
Marking this as stale due to 30 days of inactivity. It will be closed in 7 days if no further activity occurs.
i've try enclideadClusterExtraction for fpfh for each point, but it did't work,is there anyone who has tried it ,i need your help. thx very much.And i wanna get the result as follows: Surfaces with the same geometric features come together。