Loading [MathJax]/extensions/TeX/AMSsymbols.js
Open3D (C++ API)  0.14.1
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
NearestNeighborSearch.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2018-2021 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include <vector>
30 
31 #include "open3d/core/Tensor.h"
37 
38 namespace open3d {
39 namespace core {
40 namespace nns {
41 
46 public:
51  NearestNeighborSearch(const Tensor &dataset_points)
52  : dataset_points_(dataset_points){};
53 
57 
58 public:
62  bool KnnIndex();
63 
67  bool MultiRadiusIndex();
68 
74 
78  bool HybridIndex(utility::optional<double> radius = {});
79 
88  std::pair<Tensor, Tensor> KnnSearch(const Tensor &query_points, int knn);
89 
101  std::tuple<Tensor, Tensor, Tensor> FixedRadiusSearch(
102  const Tensor &query_points, double radius, bool sort = true);
103 
115  std::tuple<Tensor, Tensor, Tensor> MultiRadiusSearch(
116  const Tensor &query_points, const Tensor &radii);
117 
130  std::tuple<Tensor, Tensor, Tensor> HybridSearch(const Tensor &query_points,
131  double radius,
132  int max_knn);
133 
134 private:
135  bool SetIndex();
136 
138  void AssertNotCUDA(const Tensor &t) const;
139 
140 protected:
141  std::unique_ptr<NanoFlannIndex> nanoflann_index_;
142  std::unique_ptr<FaissIndex> faiss_index_;
143  std::unique_ptr<nns::FixedRadiusIndex> fixed_radius_index_;
144  std::unique_ptr<nns::KnnIndex> knn_index_;
146 };
147 } // namespace nns
148 } // namespace core
149 } // namespace open3d
bool FixedRadiusIndex(utility::optional< double > radius={})
Definition: NearestNeighborSearch.cpp:70
std::unique_ptr< FaissIndex > faiss_index_
Definition: NearestNeighborSearch.h:142
std::tuple< Tensor, Tensor, Tensor > HybridSearch(const Tensor &query_points, double radius, int max_knn)
Definition: NearestNeighborSearch.cpp:162
NearestNeighborSearch & operator=(const NearestNeighborSearch &)=delete
bool HybridIndex(utility::optional< double > radius={})
Definition: NearestNeighborSearch.cpp:90
std::tuple< Tensor, Tensor, Tensor > FixedRadiusSearch(const Tensor &query_points, double radius, bool sort=true)
Definition: NearestNeighborSearch.cpp:130
std::unique_ptr< NanoFlannIndex > nanoflann_index_
Definition: NearestNeighborSearch.h:141
std::unique_ptr< nns::KnnIndex > knn_index_
Definition: NearestNeighborSearch.h:144
std::tuple< Tensor, Tensor, Tensor > MultiRadiusSearch(const Tensor &query_points, const Tensor &radii)
Definition: NearestNeighborSearch.cpp:150
A Class for nearest neighbor search.
Definition: NearestNeighborSearch.h:45
Definition: Optional.h:79
std::pair< Tensor, Tensor > KnnSearch(const Tensor &query_points, int knn)
Definition: NearestNeighborSearch.cpp:109
Definition: PinholeCameraIntrinsic.cpp:35
Definition: Tensor.h:50
~NearestNeighborSearch()
Definition: NearestNeighborSearch.cpp:35
std::unique_ptr< nns::FixedRadiusIndex > fixed_radius_index_
Definition: NearestNeighborSearch.h:143
NearestNeighborSearch(const Tensor &dataset_points)
Definition: NearestNeighborSearch.h:51
bool MultiRadiusIndex()
Definition: NearestNeighborSearch.cpp:68
bool KnnIndex()
Definition: NearestNeighborSearch.cpp:42
const Tensor dataset_points_
Definition: NearestNeighborSearch.h:145