diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp index 9a7d0d980ea..00f56616e67 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp @@ -103,9 +103,10 @@ std::vector boundary_indices; mps.segmentAndRefine (regions, model_coefficients, inlier_indices, labels, label_indices, boundary_indices); - boost::shared_ptr > plane_labels = boost::make_shared > (); + boost::shared_ptr > plane_labels = boost::make_shared > (); for (size_t i = 0; i < label_indices.size (); ++i) - (*plane_labels)[i] = (label_indices[i].indices.size () > (size_t) min_plane_size); + if (label_indices[i].indices.size () > (size_t) min_plane_size) + plane_labels->insert (i); typename PointCloud::CloudVectorType clusters; typename EuclideanClusterComparator::Ptr euclidean_cluster_comparator = diff --git a/apps/src/ni_linemod.cpp b/apps/src/ni_linemod.cpp index 97886eeb3c0..d582f0a1b11 100644 --- a/apps/src/ni_linemod.cpp +++ b/apps/src/ni_linemod.cpp @@ -260,9 +260,8 @@ class NILinemod scene->points[points_above_plane->indices[i]].label = 1; euclidean_cluster_comparator->setLabels (scene); - boost::shared_ptr > exclude_labels = boost::make_shared > (); - (*exclude_labels)[0] = true; - (*exclude_labels)[1] = false; + boost::shared_ptr > exclude_labels = boost::make_shared > (); + exclude_labels->insert (0); OrganizedConnectedComponentSegmentation euclidean_segmentation (euclidean_cluster_comparator); euclidean_segmentation.setInputCloud (cloud); diff --git a/apps/src/organized_segmentation_demo.cpp b/apps/src/organized_segmentation_demo.cpp index 95e5f83ebf2..6cc273dbcdd 100644 --- a/apps/src/organized_segmentation_demo.cpp +++ b/apps/src/organized_segmentation_demo.cpp @@ -309,9 +309,10 @@ OrganizedSegmentationDemo::cloud_cb (const CloudConstPtr& cloud) if (use_clustering_ && regions.size () > 0) { - boost::shared_ptr > plane_labels = boost::make_shared > (); + boost::shared_ptr > plane_labels = boost::make_shared > (); for (size_t i = 0; i < label_indices.size (); ++i) - (*plane_labels)[i] = (label_indices[i].indices.size () > 10000); + if (label_indices[i].indices.size () > 10000) + plane_labels->insert (i); euclidean_cluster_comparator_->setInputCloud (cloud); euclidean_cluster_comparator_->setLabels (labels); diff --git a/apps/src/pcd_select_object_plane.cpp b/apps/src/pcd_select_object_plane.cpp index 1eb5338afa8..a4a26b9e82b 100644 --- a/apps/src/pcd_select_object_plane.cpp +++ b/apps/src/pcd_select_object_plane.cpp @@ -205,9 +205,8 @@ class ObjectSelection scene->points[points_above_plane->indices[i]].label = 1; euclidean_cluster_comparator->setLabels (scene); - boost::shared_ptr > exclude_labels = boost::make_shared > (); - (*exclude_labels)[0] = true; - (*exclude_labels)[1] = false; + boost::shared_ptr > exclude_labels = boost::make_shared > (); + exclude_labels->insert (0); euclidean_cluster_comparator->setExcludeLabels (exclude_labels); OrganizedConnectedComponentSegmentation euclidean_segmentation (euclidean_cluster_comparator); diff --git a/apps/src/stereo_ground_segmentation.cpp b/apps/src/stereo_ground_segmentation.cpp index 81aad6591a7..99f8874cc4b 100755 --- a/apps/src/stereo_ground_segmentation.cpp +++ b/apps/src/stereo_ground_segmentation.cpp @@ -393,9 +393,10 @@ class HRCSSegmentation pcl::PointCloud::CloudVectorType clusters; if (ground_cloud->points.size () > 0) { - boost::shared_ptr > plane_labels = boost::make_shared > (); + boost::shared_ptr > plane_labels = boost::make_shared > (); for (size_t i = 0; i < region_indices.size (); ++i) - (*plane_labels)[i] = (region_indices[i].indices.size () > mps.getMinInliers ()); + if ((region_indices[i].indices.size () > mps.getMinInliers ())) + plane_labels->insert (i); pcl::EuclideanClusterComparator::Ptr euclidean_cluster_comparator_ (new pcl::EuclideanClusterComparator ()); euclidean_cluster_comparator_->setInputCloud (cloud); diff --git a/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h b/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h index 7001c9c8d4e..911382989e9 100644 --- a/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h +++ b/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h @@ -63,9 +63,9 @@ namespace pcl typedef boost::shared_ptr > Ptr; typedef boost::shared_ptr > ConstPtr; - typedef std::map ExcludeLabelMap; - typedef boost::shared_ptr ExcludeLabelMapPtr; - typedef boost::shared_ptr ExcludeLabelMapConstPtr; + typedef std::set ExcludeLabelSet; + typedef boost::shared_ptr ExcludeLabelSetPtr; + typedef boost::shared_ptr ExcludeLabelSetConstPtr; virtual void setInputCloud (const PointCloudConstPtr& cloud) @@ -102,7 +102,7 @@ namespace pcl labels_ = labels; } - const ExcludeLabelMapConstPtr& + const ExcludeLabelSetConstPtr& getExcludeLabels () const { return exclude_labels_; @@ -112,7 +112,7 @@ namespace pcl * \param exclude_labels a vector of bools corresponding to whether or not a given label should be considered */ void - setExcludeLabels (const ExcludeLabelMapConstPtr &exclude_labels) + setExcludeLabels (const ExcludeLabelSetConstPtr &exclude_labels) { exclude_labels_ = exclude_labels; } @@ -130,12 +130,12 @@ namespace pcl const uint32_t &label1 = (*labels_)[idx1].label; const uint32_t &label2 = (*labels_)[idx2].label; - const std::map::const_iterator it1 = exclude_labels_->find (label1); - if ((it1 == exclude_labels_->end ()) || it1->second) + const std::set::const_iterator it1 = exclude_labels_->find (label1); + if (it1 == exclude_labels_->end ()) return false; - const std::map::const_iterator it2 = exclude_labels_->find (label2); - if ((it2 == exclude_labels_->end ()) || it2->second) + const std::set::const_iterator it2 = exclude_labels_->find (label2); + if (it2 == exclude_labels_->end ()) return false; } @@ -175,7 +175,7 @@ namespace pcl * If a label is not specified, it's assumed by default that it's * intended be excluded */ - ExcludeLabelMapConstPtr exclude_labels_; + ExcludeLabelSetConstPtr exclude_labels_; float distance_threshold_;