-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Move further towards KdTreeNanoflann #6413
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,35 +15,58 @@ | |
| #include <pcl/search/brute_force.h> | ||
| #include <pcl/search/kdtree.h> | ||
| #include <pcl/search/kdtree_nanoflann.h> | ||
| #include <pcl/search/octree.h> | ||
| #include <pcl/search/organized.h> | ||
|
|
||
| template<typename PointT> | ||
| pcl::search::Search<PointT> * pcl::search::autoSelectMethod(const typename pcl::PointCloud<PointT>::ConstPtr& cloud, const pcl::IndicesConstPtr& indices, bool sorted_results, pcl::search::Purpose purpose) { | ||
| pcl::search::Search<PointT> * searcher = nullptr; | ||
| if (cloud->isOrganized ()) { | ||
| searcher = new pcl::search::OrganizedNeighbor<PointT> (sorted_results); | ||
| if(searcher->setInputCloud (cloud, indices)) { // may return false if OrganizedNeighbor cannot work with the cloud, then use another search method instead | ||
| return searcher; | ||
| if constexpr (pcl::traits::has_xyz_v<PointT>) { | ||
| if (cloud->isOrganized ()) { | ||
| searcher = new pcl::search::OrganizedNeighbor<PointT> (sorted_results); | ||
| if(searcher->setInputCloud (cloud, indices)) { // may return false if OrganizedNeighbor cannot work with the cloud, then use another search method instead | ||
| return searcher; | ||
| } | ||
| delete searcher; | ||
| } | ||
| } | ||
|
|
||
| #if PCL_HAS_NANOFLANN | ||
| searcher = new pcl::search::KdTreeNanoflann<PointT> (sorted_results, (purpose == pcl::search::Purpose::one_knn_search ? 10 : 20)); | ||
| // we get the number of search dimensions as a compile-time-constant via NR_DIMS. NR_DIMS may be -1 if it is not possible to determine the dimensions at compile-time (only at run-time), however then searching may be slower. If NR_DIMS is not -1, it must be the same as the return value of getNumberOfDimensions(). | ||
| searcher = new pcl::search::KdTreeNanoflann<PointT, pcl::DefaultPointRepresentation<PointT>::NR_DIMS> (sorted_results, (purpose == pcl::search::Purpose::one_knn_search ? 10 : 20)); | ||
| if(searcher->setInputCloud (cloud, indices)) { | ||
| return searcher; | ||
| } | ||
| delete searcher; | ||
| #else | ||
| pcl::utils::ignore(purpose); | ||
| #endif | ||
|
|
||
| #if PCL_HAS_FLANN | ||
| searcher = new pcl::search::KdTree<PointT> (sorted_results); | ||
| if(searcher->setInputCloud (cloud, indices)) { | ||
| return searcher; | ||
| } | ||
| delete searcher; | ||
| #endif | ||
| // If nothing else works, use brute force method | ||
| searcher = new pcl::search::BruteForce<PointT> (sorted_results); | ||
| searcher->setInputCloud (cloud, indices); | ||
| return searcher; | ||
|
|
||
| if constexpr (pcl::traits::has_xyz_v<PointT>) { | ||
| searcher = new pcl::search::Octree<PointT> (0.01); // TODO a better heuristic to choose octree resolution? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add it as an optional agurment to
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather not add the octree resolution as an argument. I think |
||
| searcher->setSortedResults (sorted_results); | ||
| if(searcher->setInputCloud (cloud, indices)) { | ||
| return searcher; | ||
| } | ||
| delete searcher; | ||
| } | ||
|
|
||
| // If nothing else works, and the point type has xyz coordinates, use brute force method | ||
| if constexpr (pcl::traits::has_xyz_v<PointT>) { | ||
| searcher = new pcl::search::BruteForce<PointT> (sorted_results); | ||
| searcher->setInputCloud (cloud, indices); | ||
| return searcher; | ||
| } | ||
| PCL_ERROR("[pcl::search::autoSelectMethod] No suitable method found. Make sure you have nanoflann and/or FLANN installed.\n"); | ||
| return nullptr; | ||
| } | ||
|
|
||
| #define PCL_INSTANTIATE_AutoSelectMethod(T) template PCL_EXPORTS pcl::search::Search<T> * pcl::search::autoSelectMethod<T>(const typename pcl::PointCloud<T>::ConstPtr& cloud, const pcl::IndicesConstPtr& indices, bool sorted_results, pcl::search::Purpose purpose); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.