Open3D (C++ API)  0.19.0
Loading...
Searching...
No Matches
NearestNeighborSearch.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// Copyright (c) 2018-2024 www.open3d.org
5// SPDX-License-Identifier: MIT
6// ----------------------------------------------------------------------------
7
8#pragma once
9
10#include <optional>
11#include <vector>
12
13#include "open3d/core/Tensor.h"
17
18namespace open3d {
19namespace core {
20namespace nns {
21
26public:
31 // NearestNeighborSearch(const Tensor &dataset_points)
32 // : dataset_points_(dataset_points){};
33 NearestNeighborSearch(const Tensor &dataset_points,
34 const Dtype &index_dtype = core::Int32)
35 : dataset_points_(dataset_points), index_dtype_(index_dtype) {}
39
40public:
44 bool KnnIndex();
45
51 bool MultiRadiusIndex();
52
58 bool FixedRadiusIndex(std::optional<double> radius = {});
59
65 bool HybridIndex(std::optional<double> radius = {});
66
75 std::pair<Tensor, Tensor> KnnSearch(const Tensor &query_points, int knn);
76
90 std::tuple<Tensor, Tensor, Tensor> FixedRadiusSearch(
91 const Tensor &query_points, double radius, bool sort = true);
92
106 std::tuple<Tensor, Tensor, Tensor> MultiRadiusSearch(
107 const Tensor &query_points, const Tensor &radii);
108
121 std::tuple<Tensor, Tensor, Tensor> HybridSearch(const Tensor &query_points,
122 const double radius,
123 const int max_knn) const;
124
125private:
126 bool SetIndex();
127
129 void AssertCPU(const Tensor &t) const;
130
131protected:
132 std::unique_ptr<NanoFlannIndex> nanoflann_index_;
133 std::unique_ptr<nns::FixedRadiusIndex> fixed_radius_index_;
134 std::unique_ptr<nns::KnnIndex> knn_index_;
137};
138} // namespace nns
139} // namespace core
140} // namespace open3d
Definition Dtype.h:20
Definition Tensor.h:32
FixedRadiusIndex for nearest neighbor range search.
Definition FixedRadiusIndex.h:432
A Class for nearest neighbor search.
Definition NearestNeighborSearch.h:25
bool HybridIndex(std::optional< double > radius={})
Definition NearestNeighborSearch.cpp:66
bool MultiRadiusIndex()
Definition NearestNeighborSearch.cpp:32
NearestNeighborSearch(const NearestNeighborSearch &)=delete
std::unique_ptr< nns::KnnIndex > knn_index_
Definition NearestNeighborSearch.h:134
std::tuple< Tensor, Tensor, Tensor > HybridSearch(const Tensor &query_points, const double radius, const int max_knn) const
Definition NearestNeighborSearch.cpp:144
std::tuple< Tensor, Tensor, Tensor > FixedRadiusSearch(const Tensor &query_points, double radius, bool sort=true)
Definition NearestNeighborSearch.cpp:112
bool KnnIndex()
Definition NearestNeighborSearch.cpp:23
std::tuple< Tensor, Tensor, Tensor > MultiRadiusSearch(const Tensor &query_points, const Tensor &radii)
Definition NearestNeighborSearch.cpp:132
~NearestNeighborSearch()
Definition NearestNeighborSearch.cpp:16
const Tensor dataset_points_
Definition NearestNeighborSearch.h:135
NearestNeighborSearch & operator=(const NearestNeighborSearch &)=delete
std::unique_ptr< nns::FixedRadiusIndex > fixed_radius_index_
Definition NearestNeighborSearch.h:133
std::pair< Tensor, Tensor > KnnSearch(const Tensor &query_points, int knn)
Definition NearestNeighborSearch.cpp:93
std::unique_ptr< NanoFlannIndex > nanoflann_index_
Definition NearestNeighborSearch.h:132
const Dtype index_dtype_
Definition NearestNeighborSearch.h:136
NearestNeighborSearch(const Tensor &dataset_points, const Dtype &index_dtype=core::Int32)
Definition NearestNeighborSearch.h:33
const Dtype Int32
Definition Dtype.cpp:46
Definition PinholeCameraIntrinsic.cpp:16