Skip to content

Commit 310b93f

Browse files
authored
Merge pull request #2380 from ThorstenHarter/master
Correct setting of is_dense flag in SegmentDifferences
2 parents de9a5c6 + 5fc95dd commit 310b93f

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

segmentation/include/pcl/segmentation/impl/segment_differences.hpp

100644100755
Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,22 @@
4444
//////////////////////////////////////////////////////////////////////////
4545
template <typename PointT> void
4646
pcl::getPointCloudDifference (
47-
const pcl::PointCloud<PointT> &src,
48-
const pcl::PointCloud<PointT> &,
49-
double threshold, const boost::shared_ptr<pcl::search::Search<PointT> > &tree,
47+
const pcl::PointCloud<PointT> &src,
48+
double threshold,
49+
const boost::shared_ptr<pcl::search::Search<PointT> > &tree,
5050
pcl::PointCloud<PointT> &output)
5151
{
5252
// We're interested in a single nearest neighbor only
5353
std::vector<int> nn_indices (1);
5454
std::vector<float> nn_distances (1);
5555

56-
// The src indices that do not have a neighbor in tgt
56+
// The input cloud indices that do not have a neighbor in the target cloud
5757
std::vector<int> src_indices;
5858

5959
// Iterate through the source data set
6060
for (int i = 0; i < static_cast<int> (src.points.size ()); ++i)
6161
{
62+
// Ignore invalid points in the inpout cloud
6263
if (!isFinite (src.points[i]))
6364
continue;
6465
// Search for the closest point in the target data set (number of neighbors to find = 1)
@@ -67,25 +68,16 @@ pcl::getPointCloudDifference (
6768
PCL_WARN ("No neighbor found for point %lu (%f %f %f)!\n", i, src.points[i].x, src.points[i].y, src.points[i].z);
6869
continue;
6970
}
70-
71+
// Add points without a corresponding point in the target cloud to the output cloud
7172
if (nn_distances[0] > threshold)
7273
src_indices.push_back (i);
7374
}
74-
75-
// Allocate enough space and copy the basics
76-
output.points.resize (src_indices.size ());
77-
output.header = src.header;
78-
output.width = static_cast<uint32_t> (src_indices.size ());
79-
output.height = 1;
80-
//if (src.is_dense)
81-
output.is_dense = true;
82-
//else
83-
// It's not necessarily true that is_dense is false if cloud_in.is_dense is false
84-
// To verify this, we would need to iterate over all points and check for NaNs
85-
//output.is_dense = false;
8675

8776
// Copy all the data fields from the input cloud to the output one
8877
copyPointCloud (src, src_indices, output);
78+
79+
// Output is always dense, as invalid points in the input cloud are ignored
80+
output.is_dense = true;
8981
}
9082

9183
//////////////////////////////////////////////////////////////////////////
@@ -121,13 +113,12 @@ pcl::SegmentDifferences<PointT>::segment (PointCloud &output)
121113
// Send the input dataset to the spatial locator
122114
tree_->setInputCloud (target_);
123115

124-
getPointCloudDifference (*input_, *target_, distance_threshold_, tree_, output);
116+
getPointCloudDifference (*input_, distance_threshold_, tree_, output);
125117

126118
deinitCompute ();
127119
}
128120

129121
#define PCL_INSTANTIATE_SegmentDifferences(T) template class PCL_EXPORTS pcl::SegmentDifferences<T>;
130-
#define PCL_INSTANTIATE_getPointCloudDifference(T) template PCL_EXPORTS void pcl::getPointCloudDifference<T>(const pcl::PointCloud<T> &, const pcl::PointCloud<T> &, double, const boost::shared_ptr<pcl::search::Search<T> > &, pcl::PointCloud<T> &);
122+
#define PCL_INSTANTIATE_getPointCloudDifference(T) template PCL_EXPORTS void pcl::getPointCloudDifference<T>(const pcl::PointCloud<T> &, double, const boost::shared_ptr<pcl::search::Search<T> > &, pcl::PointCloud<T> &);
131123

132124
#endif // PCL_SEGMENTATION_IMPL_SEGMENT_DIFFERENCES_H_
133-

segmentation/include/pcl/segmentation/segment_differences.h

100644100755
Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,31 @@ namespace pcl
4646
////////////////////////////////////////////////////////////////////////////////////////////
4747
/** \brief Obtain the difference between two aligned point clouds as another point cloud, given a distance threshold.
4848
* \param src the input point cloud source
49-
* \param tgt the input point cloud target we need to obtain the difference against
5049
* \param threshold the distance threshold (tolerance) for point correspondences. (e.g., check if f a point p1 from
5150
* src has a correspondence > threshold than a point p2 from tgt)
52-
* \param tree the spatial locator (e.g., kd-tree) used for nearest neighbors searching built over \a tgt
51+
* \param tree the spatial locator (e.g., kd-tree) used for nearest neighbors searching built over the target cloud
5352
* \param output the resultant output point cloud difference
5453
* \ingroup segmentation
5554
*/
5655
template <typename PointT>
5756
void getPointCloudDifference (
58-
const pcl::PointCloud<PointT> &src, const pcl::PointCloud<PointT> &tgt,
59-
double threshold, const boost::shared_ptr<pcl::search::Search<PointT> > &tree,
57+
const pcl::PointCloud<PointT> &src,
58+
double threshold,
59+
const boost::shared_ptr<pcl::search::Search<PointT> > &tree,
6060
pcl::PointCloud<PointT> &output);
6161

62+
template <typename PointT>
63+
PCL_DEPRECATED("getPointCloudDifference() does not use the tgt parameter, thus it is deprecated and will be removed in future releases.")
64+
inline void getPointCloudDifference (
65+
const pcl::PointCloud<PointT> &src,
66+
const pcl::PointCloud<PointT> &tgt,
67+
double threshold,
68+
const boost::shared_ptr<pcl::search::Search<PointT> > &tree,
69+
pcl::PointCloud<PointT> &output)
70+
{
71+
getPointCloudDifference<PointT> (src, pcl::PointCloud<PointT>(), threshold, tree, output);
72+
}
73+
6274
////////////////////////////////////////////////////////////////////////////////////////////
6375
////////////////////////////////////////////////////////////////////////////////////////////
6476
////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)