Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent addition of duplicate keys in PFHEstimation buffer #1701

Merged
merged 1 commit into from
Aug 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion features/include/pcl/features/impl/pfh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ pcl::PFHEstimation<PointInT, PointNT, PointOutT>::computePointPFHSignature (
float hist_incr = 100.0f / static_cast<float> (indices.size () * (indices.size () - 1) / 2);

std::pair<int, int> key;
bool key_found = false;

// Iterate over all the points in the neighborhood
for (size_t i_idx = 0; i_idx < indices.size (); ++i_idx)
{
Expand Down Expand Up @@ -96,13 +98,18 @@ pcl::PFHEstimation<PointInT, PointNT, PointOutT>::computePointPFHSignature (
// Check to see if we already estimated this pair in the global hashmap
std::map<std::pair<int, int>, Eigen::Vector4f, std::less<std::pair<int, int> >, Eigen::aligned_allocator<std::pair<const std::pair<int, int>, Eigen::Vector4f> > >::iterator fm_it = feature_map_.find (key);
if (fm_it != feature_map_.end ())
{
pfh_tuple_ = fm_it->second;
key_found = true;
}
else
{
// Compute the pair NNi to NNj
if (!computePairFeatures (cloud, normals, indices[i_idx], indices[j_idx],
pfh_tuple_[0], pfh_tuple_[1], pfh_tuple_[2], pfh_tuple_[3]))
continue;

key_found = false;
}
}
else
Expand Down Expand Up @@ -133,7 +140,7 @@ pcl::PFHEstimation<PointInT, PointNT, PointOutT>::computePointPFHSignature (
}
pfh_histogram[h_index] += hist_incr;

if (use_cache_)
if (use_cache_ && !key_found)
{
// Save the value in the hashmap
feature_map_[key] = pfh_tuple_;
Expand Down