Open3D (C++ API)  0.18.0+252c867
KDTreeFlann.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <Eigen/Core>
11 #include <memory>
12 #include <vector>
13 
17 
19 namespace nanoflann {
20 struct metric_L2;
21 template <class MatrixType, int DIM, class Distance, bool row_major>
22 struct KDTreeEigenMatrixAdaptor;
23 } // namespace nanoflann
25 
26 namespace open3d {
27 namespace geometry {
28 
32 class KDTreeFlann {
33 public:
35  KDTreeFlann();
39  KDTreeFlann(const Eigen::MatrixXd &data);
43  KDTreeFlann(const Geometry &geometry);
49  ~KDTreeFlann();
50  KDTreeFlann(const KDTreeFlann &) = delete;
51  KDTreeFlann &operator=(const KDTreeFlann &) = delete;
52 
53 public:
57  bool SetMatrixData(const Eigen::MatrixXd &data);
61  bool SetGeometry(const Geometry &geometry);
65  bool SetFeature(const pipelines::registration::Feature &feature);
66 
67  template <typename T>
68  int Search(const T &query,
69  const KDTreeSearchParam &param,
70  std::vector<int> &indices,
71  std::vector<double> &distance2) const;
72 
73  template <typename T>
74  int SearchKNN(const T &query,
75  int knn,
76  std::vector<int> &indices,
77  std::vector<double> &distance2) const;
78 
79  template <typename T>
80  int SearchRadius(const T &query,
81  double radius,
82  std::vector<int> &indices,
83  std::vector<double> &distance2) const;
84 
85  template <typename T>
86  int SearchHybrid(const T &query,
87  double radius,
88  int max_nn,
89  std::vector<int> &indices,
90  std::vector<double> &distance2) const;
91 
92 private:
97  bool SetRawData(const Eigen::Map<const Eigen::MatrixXd> &data);
98 
99 protected:
100  using KDTree_t = nanoflann::KDTreeEigenMatrixAdaptor<const Eigen::MatrixXd,
101  -1,
102  nanoflann::metric_L2,
103  false>;
104 
105  Eigen::MatrixXd data_;
106  std::unique_ptr<KDTree_t> nanoflann_index_;
107 };
108 
109 } // namespace geometry
110 } // namespace open3d
The base geometry class.
Definition: Geometry.h:18
KDTree with FLANN for nearest neighbor search.
Definition: KDTreeFlann.h:32
int Search(const T &query, const KDTreeSearchParam &param, std::vector< int > &indices, std::vector< double > &distance2) const
Definition: KDTreeFlann.cpp:69
KDTreeFlann()
Default Constructor.
Definition: KDTreeFlann.cpp:25
bool SetGeometry(const Geometry &geometry)
Definition: KDTreeFlann.cpp:42
bool SetMatrixData(const Eigen::MatrixXd &data)
Definition: KDTreeFlann.cpp:37
int SearchRadius(const T &query, double radius, std::vector< int > &indices, std::vector< double > &distance2) const
Definition: KDTreeFlann.cpp:115
int SearchKNN(const T &query, int knn, std::vector< int > &indices, std::vector< double > &distance2) const
Definition: KDTreeFlann.cpp:93
~KDTreeFlann()
Definition: KDTreeFlann.cpp:35
bool SetFeature(const pipelines::registration::Feature &feature)
Definition: KDTreeFlann.cpp:64
int SearchHybrid(const T &query, double radius, int max_nn, std::vector< int > &indices, std::vector< double > &distance2) const
Definition: KDTreeFlann.cpp:140
nanoflann::KDTreeEigenMatrixAdaptor< const Eigen::MatrixXd, -1, nanoflann::metric_L2, false > KDTree_t
Definition: KDTreeFlann.h:103
KDTreeFlann & operator=(const KDTreeFlann &)=delete
Eigen::MatrixXd data_
Definition: KDTreeFlann.h:105
std::unique_ptr< KDTree_t > nanoflann_index_
Definition: KDTreeFlann.h:106
KDTreeFlann(const KDTreeFlann &)=delete
Base class for KDTree search parameters.
Definition: KDTreeSearchParam.h:16
Class to store featrues for registration.
Definition: Feature.h:30
const char const char value recording_handle imu_sample recording_handle uint8_t data
Definition: K4aPlugin.cpp:269
Definition: PinholeCameraIntrinsic.cpp:16