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

[keypoints] Prefer lambdas over bind. #3171

Merged
merged 1 commit into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
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
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); });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// comparator for responses intensity
bool
greaterIntensityAtIndices (int a, int b) const
{
return (response_->at (a).intensity > response_->at (b).intensity);
}

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); });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// comparator for responses intensity
inline bool
greaterCornernessAtIndices (int a, int b) const
{
return (response_->points [a] > response_->points [b]);
}


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); });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/** Comparator for responses intensity
* \return true if \a response_ at index \aa is greater than response at index \ab
*/
inline bool
greaterCornernessAtIndices (int a, int b) const
{
return (response_->points [a] > response_->points [b]);
}


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