Skip to content

Move further towards KdTreeNanoflann#6413

Open
mvieth wants to merge 3 commits intoPointCloudLibrary:masterfrom
mvieth:nanoflann_default4
Open

Move further towards KdTreeNanoflann#6413
mvieth wants to merge 3 commits intoPointCloudLibrary:masterfrom
mvieth:nanoflann_default4

Conversation

@mvieth
Copy link
Member

@mvieth mvieth commented Mar 8, 2026

Extend autoSelectMethod to types that do not have xyz-coordinate (i.e. features types)

@mvieth mvieth force-pushed the nanoflann_default4 branch 3 times, most recently from 7bb1400 to 9667857 Compare March 9, 2026 14:59
@mvieth mvieth added changelog: enhancement Meta-information for changelog generation module: search labels Mar 9, 2026
@mvieth mvieth force-pushed the nanoflann_default4 branch 2 times, most recently from ccbc4e7 to 4c16e08 Compare March 10, 2026 20:25
Extend `autoSelectMethod` to types that do not have xyz-coordinates (i.e. features types)
@mvieth mvieth force-pushed the nanoflann_default4 branch from 4c16e08 to 1a469fc Compare March 11, 2026 09:47
@mvieth mvieth changed the title More further towards KdTreeNanoflann Move further towards KdTreeNanoflann Mar 11, 2026
@mvieth mvieth marked this pull request as ready for review March 11, 2026 14:50
@mvieth mvieth requested a review from Copilot March 11, 2026 14:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends pcl::search::autoSelectMethod usage beyond XYZ point types (notably toward feature/descriptor types) and updates several tools and registration components to rely on the auto-selected search backend, while also introducing compile-time dimension constants (NR_DIMS) in point representations to support KdTreeNanoflann specialization.

Changes:

  • Replace direct KdTree/KdTreeFLANN usage with pcl::search::autoSelectMethod(...) in tools and registration feature search paths.
  • Broaden precompiled instantiations of AutoSelectMethod and update autoSelectMethod internals to avoid xyz-only code paths for non-xyz types.
  • Add NR_DIMS compile-time constants to point/feature representations and add a unit test to assert consistency with runtime dimensions.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tools/pcd_viewer.cpp Switch point picking search to autoSelectMethod and Search::Ptr.
tools/compute_hausdorff.cpp Use autoSelectMethod for 1-NN distance computations.
tools/boundary_estimation.cpp Remove unused commented search-method line.
test/common/test_common.cpp Add coverage asserting DefaultPointRepresentation::NR_DIMS matches runtime dimensions.
search/src/auto.cpp Instantiate AutoSelectMethod for PCL_POINT_TYPES (incl. feature types).
search/include/pcl/search/impl/auto.hpp Extend selection logic for non-xyz types and specialize KdTreeNanoflann with NR_DIMS.
registration/include/pcl/registration/sample_consensus_prerejective.h Change feature tree type to pcl::search::Search<FeatureT>::Ptr.
registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp Build feature search tree via autoSelectMethod.
registration/include/pcl/registration/ia_ransac.h Change feature tree type to pcl::search::Search<FeatureT>::Ptr and adjust ctor init.
registration/include/pcl/registration/impl/ia_ransac.hpp Build feature search tree via autoSelectMethod.
registration/include/pcl/registration/ia_fpcs.h Replace reciprocal kd-tree alias with pcl::search::Search<PointSource>.
registration/include/pcl/registration/impl/ia_fpcs.hpp Use autoSelectMethod for intermediate-point radius searches.
people/include/pcl/people/impl/ground_based_people_detection_app.hpp Rely on EuclideanClusterExtraction’s internal auto-selected tree (remove manual tree wiring).
common/include/pcl/point_representation.h Add NR_DIMS for default point/feature representations and propagate into specializations.
common/include/pcl/impl/point_types.hpp Add descriptorSize trait specialization for NormalBasedSignature12.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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?
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add it as an optional agurment to autoSelectMethod ?
Else there is no way to change it - as it can't be done afterwards.
One can still create an octree "manually" if one knows it better fits.

Copy link
Member Author

Choose a reason for hiding this comment

The 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 autoSelectMethod should hide any details related to the specific search method used, and determine all settings itself (e.g. resolution, or number of points per node for KdTreeNanoflann). I think having a resolution argument would kind of defeat the purpose of autoSelectMethod: being able to just request a search object without worrying which method is used or with which parameters. And like you said - if someone specifically wants an octree with a certain resolution, they can always create it manually and e.g. pass it to any PCL class via setSearchMethod.
I have added octree here only preliminarily because I think it will be faster than the BruteForce search even if the octree resolution is not perfectly chosen. I think in the future we could try to determine a good resolution via the 3D bounding box of the cloud, or we check whether we make the dynamic depth feature available in pcl::search::Octree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: enhancement Meta-information for changelog generation module: search

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants