Skip to content

Commit

Permalink
Replace exclude_labels map for a set in EuclideanClusterComparator
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioRAgostinho committed Nov 21, 2017
1 parent 25725d9 commit 5db45b0
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@
std::vector<pcl::PointIndices> boundary_indices;
mps.segmentAndRefine (regions, model_coefficients, inlier_indices, labels, label_indices, boundary_indices);

boost::shared_ptr<std::map<uint32_t, bool> > plane_labels = boost::make_shared<std::map<uint32_t, bool> > ();
boost::shared_ptr<std::set<uint32_t> > plane_labels = boost::make_shared<std::set<uint32_t> > ();
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<PointT>::CloudVectorType clusters;

typename EuclideanClusterComparator<PointT, pcl::Normal, pcl::Label>::Ptr euclidean_cluster_comparator =
Expand Down
5 changes: 2 additions & 3 deletions apps/src/ni_linemod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,8 @@ class NILinemod
scene->points[points_above_plane->indices[i]].label = 1;
euclidean_cluster_comparator->setLabels (scene);

boost::shared_ptr<std::map<uint32_t, bool> > exclude_labels = boost::make_shared<std::map<uint32_t, bool> > ();
(*exclude_labels)[0] = true;
(*exclude_labels)[1] = false;
boost::shared_ptr<std::set<uint32_t> > exclude_labels = boost::make_shared<std::set<uint32_t> > ();
exclude_labels->insert (0);

OrganizedConnectedComponentSegmentation<PointT, Label> euclidean_segmentation (euclidean_cluster_comparator);
euclidean_segmentation.setInputCloud (cloud);
Expand Down
5 changes: 3 additions & 2 deletions apps/src/organized_segmentation_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,10 @@ OrganizedSegmentationDemo::cloud_cb (const CloudConstPtr& cloud)

if (use_clustering_ && regions.size () > 0)
{
boost::shared_ptr<std::map<uint32_t, bool> > plane_labels = boost::make_shared<std::map<uint32_t, bool> > ();
boost::shared_ptr<std::set<uint32_t> > plane_labels = boost::make_shared<std::set<uint32_t> > ();
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);
Expand Down
5 changes: 2 additions & 3 deletions apps/src/pcd_select_object_plane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,8 @@ class ObjectSelection
scene->points[points_above_plane->indices[i]].label = 1;
euclidean_cluster_comparator->setLabels (scene);

boost::shared_ptr<std::map<uint32_t, bool> > exclude_labels = boost::make_shared<std::map<uint32_t, bool> > ();
(*exclude_labels)[0] = true;
(*exclude_labels)[1] = false;
boost::shared_ptr<std::set<uint32_t> > exclude_labels = boost::make_shared<std::set<uint32_t> > ();
exclude_labels->insert (0);
euclidean_cluster_comparator->setExcludeLabels (exclude_labels);

OrganizedConnectedComponentSegmentation<PointT, Label> euclidean_segmentation (euclidean_cluster_comparator);
Expand Down
5 changes: 3 additions & 2 deletions apps/src/stereo_ground_segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,10 @@ class HRCSSegmentation
pcl::PointCloud<PointT>::CloudVectorType clusters;
if (ground_cloud->points.size () > 0)
{
boost::shared_ptr<std::map<uint32_t, bool> > plane_labels = boost::make_shared<std::map<uint32_t, bool> > ();
boost::shared_ptr<std::set<uint32_t> > plane_labels = boost::make_shared<std::set<uint32_t> > ();
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<PointT, pcl::Normal, pcl::Label>::Ptr euclidean_cluster_comparator_ (new pcl::EuclideanClusterComparator<PointT, pcl::Normal, pcl::Label> ());
euclidean_cluster_comparator_->setInputCloud (cloud);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ namespace pcl
typedef boost::shared_ptr<EuclideanClusterComparator2<PointT, PointLT> > Ptr;
typedef boost::shared_ptr<const EuclideanClusterComparator2<PointT, PointLT> > ConstPtr;

typedef std::map<uint32_t, bool> ExcludeLabelMap;
typedef boost::shared_ptr<ExcludeLabelMap> ExcludeLabelMapPtr;
typedef boost::shared_ptr<const ExcludeLabelMap> ExcludeLabelMapConstPtr;
typedef std::set<uint32_t> ExcludeLabelSet;
typedef boost::shared_ptr<ExcludeLabelSet> ExcludeLabelSetPtr;
typedef boost::shared_ptr<const ExcludeLabelSet> ExcludeLabelSetConstPtr;

virtual void
setInputCloud (const PointCloudConstPtr& cloud)
Expand Down Expand Up @@ -102,7 +102,7 @@ namespace pcl
labels_ = labels;
}

const ExcludeLabelMapConstPtr&
const ExcludeLabelSetConstPtr&
getExcludeLabels () const
{
return exclude_labels_;
Expand All @@ -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;
}
Expand All @@ -130,12 +130,12 @@ namespace pcl
const uint32_t &label1 = (*labels_)[idx1].label;
const uint32_t &label2 = (*labels_)[idx2].label;

const std::map<uint32_t, bool>::const_iterator it1 = exclude_labels_->find (label1);
if ((it1 == exclude_labels_->end ()) || it1->second)
const std::set<uint32_t>::const_iterator it1 = exclude_labels_->find (label1);
if (it1 == exclude_labels_->end ())
return false;

const std::map<uint32_t, bool>::const_iterator it2 = exclude_labels_->find (label2);
if ((it2 == exclude_labels_->end ()) || it2->second)
const std::set<uint32_t>::const_iterator it2 = exclude_labels_->find (label2);
if (it2 == exclude_labels_->end ())
return false;
}

Expand Down Expand Up @@ -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_;

Expand Down

0 comments on commit 5db45b0

Please sign in to comment.