Skip to content

Commit

Permalink
Merge pull request #3171 from SergioRAgostinho/bind-keypoints
Browse files Browse the repository at this point in the history
[keypoints] Prefer lambdas over bind.
  • Loading branch information
taketwo authored Jun 19, 2019
2 parents 07aea52 + 8d76646 commit b5d28c2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
3 changes: 1 addition & 2 deletions keypoints/include/pcl/keypoints/impl/harris_2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ pcl::HarrisKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (PointCl
}
else
{
std::sort (indices_->begin (), indices_->end (),
boost::bind (&HarrisKeypoint2D::greaterIntensityAtIndices, this, _1, _2));
std::sort (indices_->begin (), indices_->end (), [this] (int p1, int p2) { return greaterIntensityAtIndices (p1, p2); });
float threshold = threshold_ * response_->points[indices_->front ()].intensity;
output.clear ();
output.reserve (response_->size());
Expand Down
26 changes: 16 additions & 10 deletions keypoints/include/pcl/keypoints/impl/keypoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,18 @@ pcl::Keypoint<PointInT, PointOutT>::initCompute ()
if (surface_ == input_) // if the two surfaces are the same
{
// Declare the search locator definition
int (KdTree::*radiusSearch)(int index, double radius, std::vector<int> &k_indices,
std::vector<float> &k_distances, unsigned int max_nn) const = &KdTree::radiusSearch;
search_method_ = boost::bind (radiusSearch, boost::ref (tree_), _1, _2, _3, _4, 0);
search_method_ = [this] (int index, double radius, std::vector<int> &k_indices, std::vector<float> &k_distances)
{
return tree_->radiusSearch (index, radius, k_indices, k_distances, 0);
};
}
else
{
// Declare the search locator definition
int (KdTree::*radiusSearchSurface)(const PointCloudIn &cloud, int index, double radius, std::vector<int> &k_indices,
std::vector<float> &k_distances, unsigned int max_nn) const = &KdTree::radiusSearch;
search_method_surface_ = boost::bind (radiusSearchSurface, boost::ref (tree_), _1, _2, _3, _4, _5, 0);
search_method_surface_ = [this] (const PointCloudIn &cloud, int index, double radius, std::vector<int> &k_indices, std::vector<float> &k_distances)
{
return tree_->radiusSearch (cloud, index, radius, k_indices, k_distances, 0);
};
}
}
}
Expand All @@ -96,14 +98,18 @@ pcl::Keypoint<PointInT, PointOutT>::initCompute ()
if (surface_ == input_) // if the two surfaces are the same
{
// Declare the search locator definition
int (KdTree::*nearestKSearch)(int index, int k, std::vector<int> &k_indices, std::vector<float> &k_distances) const = &KdTree::nearestKSearch;
search_method_ = boost::bind (nearestKSearch, boost::ref (tree_), _1, _2, _3, _4);
search_method_ = [this] (int index, int k, std::vector<int> &k_indices, std::vector<float> &k_distances)
{
return tree_->nearestKSearch (index, k, k_indices, k_distances);
};
}
else
{
// Declare the search locator definition
int (KdTree::*nearestKSearchSurface)(const PointCloudIn &cloud, int index, int k, std::vector<int> &k_indices, std::vector<float> &k_distances) const = &KdTree::nearestKSearch;
search_method_surface_ = boost::bind (nearestKSearchSurface, boost::ref (tree_), _1, _2, _3, _4, _5);
search_method_surface_ = [this] (const PointCloudIn &cloud, int index, int k, std::vector<int> &k_indices, std::vector<float> &k_distances)
{
return tree_->nearestKSearch (cloud, index, k, k_indices, k_distances);
};
}
}
else
Expand Down
3 changes: 1 addition & 2 deletions keypoints/include/pcl/keypoints/impl/trajkovic_2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ pcl::TrajkovicKeypoint2D<PointInT, PointOutT, IntensityT>::detectKeypoints (Poin

// Non maximas suppression
std::vector<int> indices = *indices_;
std::sort (indices.begin (), indices.end (),
boost::bind (&TrajkovicKeypoint2D::greaterCornernessAtIndices, this, _1, _2));
std::sort (indices.begin (), indices.end (), [this] (int p1, int p2) { return greaterCornernessAtIndices (p1, p2); });

output.clear ();
output.reserve (input_->size ());
Expand Down
3 changes: 1 addition & 2 deletions keypoints/include/pcl/keypoints/impl/trajkovic_3d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ pcl::TrajkovicKeypoint3D<PointInT, PointOutT, NormalT>::detectKeypoints (PointCl
}
// Non maximas suppression
std::vector<int> indices = *indices_;
std::sort (indices.begin (), indices.end (),
boost::bind (&TrajkovicKeypoint3D::greaterCornernessAtIndices, this, _1, _2));
std::sort (indices.begin (), indices.end (), [this] (int p1, int p2) { return greaterCornernessAtIndices (p1, p2); });

output.clear ();
output.reserve (input_->size ());
Expand Down
2 changes: 1 addition & 1 deletion keypoints/include/pcl/keypoints/keypoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@

// PCL includes
#include <pcl/pcl_base.h>
#include <boost/bind.hpp>
#include <pcl/search/pcl_search.h>
#include <pcl/pcl_config.h>

#include <functional>

namespace pcl
Expand Down

0 comments on commit b5d28c2

Please sign in to comment.