Skip to content

Commit c96248b

Browse files
authored
Merge pull request #5792 from daohu527/master
fix: remove unnecessary indices erase in extract_clusters
2 parents cb33bf7 + 1f73950 commit c96248b

3 files changed

Lines changed: 5 additions & 11 deletions

File tree

segmentation/include/pcl/segmentation/extract_clusters.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,8 @@ namespace pcl
179179
for (std::size_t j = 0; j < seed_queue.size (); ++j)
180180
r.indices[j] = seed_queue[j];
181181

182-
// These two lines should not be needed: (can anyone confirm?) -FF
182+
// After clustering, indices are out of order, so sort them
183183
std::sort (r.indices.begin (), r.indices.end ());
184-
r.indices.erase (std::unique (r.indices.begin (), r.indices.end ()), r.indices.end ());
185184

186185
r.header = cloud.header;
187186
clusters.push_back (r); // We could avoid a copy by working directly in the vector
@@ -299,9 +298,8 @@ namespace pcl
299298
for (std::size_t j = 0; j < seed_queue.size (); ++j)
300299
r.indices[j] = seed_queue[j];
301300

302-
// These two lines should not be needed: (can anyone confirm?) -FF
301+
// After clustering, indices are out of order, so sort them
303302
std::sort (r.indices.begin (), r.indices.end ());
304-
r.indices.erase (std::unique (r.indices.begin (), r.indices.end ()), r.indices.end ());
305303

306304
r.header = cloud.header;
307305
clusters.push_back (r);

segmentation/include/pcl/segmentation/impl/extract_clusters.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ pcl::extractEuclideanClusters (const PointCloud<PointT> &cloud,
106106
for (std::size_t j = 0; j < seed_queue.size (); ++j)
107107
r.indices[j] = seed_queue[j];
108108

109-
// These two lines should not be needed: (can anyone confirm?) -FF
109+
// After clustering, indices are out of order, so sort them
110110
std::sort (r.indices.begin (), r.indices.end ());
111-
r.indices.erase (std::unique (r.indices.begin (), r.indices.end ()), r.indices.end ());
112111

113112
r.header = cloud.header;
114113
clusters.push_back (r); // We could avoid a copy by working directly in the vector
@@ -203,10 +202,8 @@ pcl::extractEuclideanClusters (const PointCloud<PointT> &cloud,
203202
// This is the only place where indices come into play
204203
r.indices[j] = seed_queue[j];
205204

206-
// These two lines should not be needed: (can anyone confirm?) -FF
207-
//r.indices.assign(seed_queue.begin(), seed_queue.end());
205+
// After clustering, indices are out of order, so sort them
208206
std::sort (r.indices.begin (), r.indices.end ());
209-
r.indices.erase (std::unique (r.indices.begin (), r.indices.end ()), r.indices.end ());
210207

211208
r.header = cloud.header;
212209
clusters.push_back (r); // We could avoid a copy by working directly in the vector

segmentation/include/pcl/segmentation/impl/extract_labeled_clusters.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,8 @@ pcl::extractLabeledEuclideanClusters(
129129
r.indices.resize(seed_queue.size());
130130
for (std::size_t j = 0; j < seed_queue.size(); ++j)
131131
r.indices[j] = seed_queue[j];
132-
132+
// After clustering, indices are out of order, so sort them
133133
std::sort(r.indices.begin(), r.indices.end());
134-
r.indices.erase(std::unique(r.indices.begin(), r.indices.end()), r.indices.end());
135134

136135
r.header = cloud.header;
137136
labeled_clusters[cloud[i].label].push_back(

0 commit comments

Comments
 (0)