私は、PCLのポイントクラウドライブラリを使用して私の部屋のポイントクラウドのセグメント成長を実行しています。 色の雲は次のようになります。 領域成長セグメンテーションクラスタが間違っていますか?
ご覧のとおり、ほとんどのクラスタは表面に沿って見えます。私はseparatedly各クラスタを表示するとき はしかし、これらの結果の一部を以下に示します。
明らかクラスタは色の雲と同じではありませんが、私は理由を理解いけません。 私は分離点群にクラスタを保存するために、このコードを使用しています:
//Store clusters into new pcls and all the clusters in an array of pcls
std::vector<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> clusters_pcl;
for (int i = 0; i < clusters.size(); ++i) {
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_cluster(
new pcl::PointCloud<pcl::PointXYZRGB>);
cloud_cluster->width = clusters[i].indices.size();
cloud_cluster->height = 1;
cloud_cluster->is_dense = true;
for (int j = 0; j < clusters[i].indices.size(); ++j) {
//Take the corresponding point of the filtered cloud from the indices for the new pcl
cloud_cluster->push_back(
point_cloud_ptr->at(clusters[i].indices[j]));
}
indices2.clear();
//pcl::removeNaNFromPointCloud(*cloud_cluster, *cloud_cluster, indices2);
clusters_pcl.push_back(cloud_cluster);
}
は、それが何か間違ったことをやっているか、地域の出力がセグメンテーションは、実際に右成長している私のコードですか?
乾杯
------------- EDIT -----------------
Hereは、点群であるIテストのために使用しています。ここで
は、チュートリアルのいずれかに類似した、セグメンテーションコードを成長させ、完全な領域である:
std::vector<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> region_growing_segmentation(
pcl::PointCloud<pcl::PointXYZRGB>::Ptr point_cloud_ptr) {
pcl::PointCloud<pcl::PointXYZRGB>& point_cloud = *point_cloud_ptr;
std::vector<int> indices2;
// Create the filtering object: downsample the dataset using a leaf size of 1cm
pcl::VoxelGrid<pcl::PointXYZRGB> vg;
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_filtered(
new pcl::PointCloud<pcl::PointXYZRGB>);
vg.setInputCloud(point_cloud_ptr);
vg.setLeafSize(0.025f, 0.025f, 0.025f);
vg.filter(*cloud_filtered);
std::cout << "PointCloud after filtering has: "
<< cloud_filtered->points.size() << " data points." << std::endl;
pcl::search::Search<pcl::PointXYZRGB>::Ptr tree = boost::shared_ptr<
pcl::search::Search<pcl::PointXYZRGB> >(
new pcl::search::KdTree<pcl::PointXYZRGB>);
pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>);
pcl::NormalEstimation<pcl::PointXYZRGB, pcl::Normal> normal_estimator;
normal_estimator.setSearchMethod(tree);
normal_estimator.setInputCloud(cloud_filtered);
normal_estimator.setKSearch(50);
normal_estimator.compute(*normals);
pcl::RegionGrowing<pcl::PointXYZRGB, pcl::Normal> reg;
reg.setMinClusterSize(50);
reg.setMaxClusterSize(1000000);
reg.setSearchMethod(tree);
reg.setNumberOfNeighbours(100);
reg.setInputCloud(cloud_filtered);
reg.setInputNormals(normals);
reg.setSmoothnessThreshold(5.0/180.0 * M_PI);
reg.setCurvatureThreshold(1);
std::vector<pcl::PointIndices> clusters;
reg.extract(clusters);
pcl::PointCloud<pcl::PointXYZRGB>::Ptr colored_cloud =
reg.getColoredCloud();
pcl::visualization::CloudViewer viewer("Cluster viewer");
viewer.showCloud(colored_cloud);
while (!viewer.wasStopped()) {
}
std::vector<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> clusters_pcl;
for (int i = 0; i < clusters.size(); ++i) {
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_cluster(
new pcl::PointCloud<pcl::PointXYZRGB>);
cloud_cluster->width = clusters[i].indices.size();
cloud_cluster->height = 1;
cloud_cluster->is_dense = true;
for (int j = 0; j < clusters[i].indices.size(); ++j) {
//Take the corresponding point of the filtered cloud from the indices for the new pcl
cloud_cluster->push_back(
point_cloud_ptr->at(clusters[i].indices[j]));
}
indices2.clear();
//pcl::removeNaNFromPointCloud(*cloud_cluster, *cloud_cluster, indices2);
clusters_pcl.push_back(cloud_cluster);
}
return clusters_pcl;
}
こんにちは、答えに感謝を。しかし、私はそれを試して、結果は似ている、まだ私はなぜこれが起こっているのかわからない –
うーん、あなたは問題を複製するコードの最小限の完全なバージョンを投稿することができますか?そしてポイントクラウドの例? – brad
こんにちは、遅い回答申し訳ありませんが、コード(私のオリジナル)とポイントクラウドは現在ポストにあります –