Open3D (C++ API)  0.11.0
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 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"
33 
34 namespace open3d {
35 namespace core {
36 namespace nns {
37 
42 public:
47  NearestNeighborSearch(const Tensor &dataset_points)
48  : dataset_points_(dataset_points) {
49  AssertNotCUDA(dataset_points);
50  };
51 
55 
56 public:
60  bool KnnIndex();
61 
65  bool MultiRadiusIndex();
66 
70  bool FixedRadiusIndex();
71 
75  bool HybridIndex();
76 
84  std::pair<Tensor, Tensor> KnnSearch(const Tensor &query_points, int knn);
85 
97  std::tuple<Tensor, Tensor, Tensor> FixedRadiusSearch(
98  const Tensor &query_points, double radius);
99 
111  std::tuple<Tensor, Tensor, Tensor> MultiRadiusSearch(
112  const Tensor &query_points, const Tensor &radii);
113 
124  std::pair<Tensor, Tensor> HybridSearch(const Tensor &query_points,
125  double radius,
126  int max_knn);
127 
128 private:
129  bool SetIndex();
130 
132  void AssertNotCUDA(const Tensor &t) const;
133 
134 protected:
135  std::unique_ptr<NanoFlannIndex> nanoflann_index_;
137 };
138 } // namespace nns
139 } // namespace core
140 } // namespace open3d
NearestNeighborSearch & operator=(const NearestNeighborSearch &)=delete
std::unique_ptr< NanoFlannIndex > nanoflann_index_
Definition: NearestNeighborSearch.h:135
std::tuple< Tensor, Tensor, Tensor > FixedRadiusSearch(const Tensor &query_points, double radius)
Definition: NearestNeighborSearch.cpp:57
std::tuple< Tensor, Tensor, Tensor > MultiRadiusSearch(const Tensor &query_points, const Tensor &radii)
Definition: NearestNeighborSearch.cpp:72
A Class for nearest neighbor search.
Definition: NearestNeighborSearch.h:41
std::pair< Tensor, Tensor > HybridSearch(const Tensor &query_points, double radius, int max_knn)
Definition: NearestNeighborSearch.cpp:93
std::pair< Tensor, Tensor > KnnSearch(const Tensor &query_points, int knn)
Definition: NearestNeighborSearch.cpp:47
Definition: PinholeCameraIntrinsic.cpp:35
Definition: Tensor.h:48
~NearestNeighborSearch()
Definition: NearestNeighborSearch.cpp:36
bool HybridIndex()
Definition: NearestNeighborSearch.cpp:45
bool FixedRadiusIndex()
Definition: NearestNeighborSearch.cpp:44
NearestNeighborSearch(const Tensor &dataset_points)
Definition: NearestNeighborSearch.h:47
bool MultiRadiusIndex()
Definition: NearestNeighborSearch.cpp:43
bool KnnIndex()
Definition: NearestNeighborSearch.cpp:42
const Tensor dataset_points_
Definition: NearestNeighborSearch.h:136