Open3D (C++ API)  0.19.0
Loading...
Searching...
No Matches
open3d::core::nns::NearestNeighborSearch Class Reference

A Class for nearest neighbor search. More...

#include <NearestNeighborSearch.h>

Public Member Functions

 NearestNeighborSearch (const Tensor &dataset_points, const Dtype &index_dtype=core::Int32)
 ~NearestNeighborSearch ()
 NearestNeighborSearch (const NearestNeighborSearch &)=delete
NearestNeighborSearchoperator= (const NearestNeighborSearch &)=delete
bool KnnIndex ()
bool MultiRadiusIndex ()
bool FixedRadiusIndex (utility::optional< double > radius={})
bool HybridIndex (utility::optional< double > radius={})
std::pair< Tensor, TensorKnnSearch (const Tensor &query_points, int knn)
std::tuple< Tensor, Tensor, TensorFixedRadiusSearch (const Tensor &query_points, double radius, bool sort=true)
std::tuple< Tensor, Tensor, TensorMultiRadiusSearch (const Tensor &query_points, const Tensor &radii)
std::tuple< Tensor, Tensor, TensorHybridSearch (const Tensor &query_points, const double radius, const int max_knn) const

Protected Attributes

std::unique_ptr< NanoFlannIndexnanoflann_index_
std::unique_ptr< nns::FixedRadiusIndexfixed_radius_index_
std::unique_ptr< nns::KnnIndexknn_index_
const Tensor dataset_points_
const Dtype index_dtype_

Detailed Description

A Class for nearest neighbor search.

Constructor & Destructor Documentation

◆ NearestNeighborSearch() [1/2]

open3d::core::nns::NearestNeighborSearch::NearestNeighborSearch ( const Tensor & dataset_points,
const Dtype & index_dtype = core::Int32 )
inline

Constructor.

Parameters
dataset_pointsDataset points for constructing search index. Must be 2D, with shape {n, d}. SYCL tensors are not yet supported.

◆ ~NearestNeighborSearch()

open3d::core::nns::NearestNeighborSearch::~NearestNeighborSearch ( )

◆ NearestNeighborSearch() [2/2]

open3d::core::nns::NearestNeighborSearch::NearestNeighborSearch ( const NearestNeighborSearch & )
delete

Member Function Documentation

◆ FixedRadiusIndex()

bool open3d::core::nns::NearestNeighborSearch::FixedRadiusIndex ( utility::optional< double > radius = {})

Set index for fixed-radius search.

Parameters
radiusoptional radius parameter. required for gpu fixed radius index.
Returns
Returns true if building index success, otherwise false.

◆ FixedRadiusSearch()

std::tuple< Tensor, Tensor, Tensor > open3d::core::nns::NearestNeighborSearch::FixedRadiusSearch ( const Tensor & query_points,
double radius,
bool sort = true )

Perform fixed radius search. All query points share the same radius.

Parameters
query_pointsData points for querying. Must be 2D, with shape {n, d}.
radiusRadius.
sortSort the results by distance. Default is True.
Returns
Tuple of Tensors, (indices, distances, num_neighbors):
  • indices: Tensor of shape {total_number_of_neighbors,}, with dtype same as index_dtype_.
  • distances: Tensor of shape {total_number_of_neighbors,}, same dtype with query_points. The distances are squared L2 distances.
  • num_neighbors: Tensor of shape {n+1,}, with dtype Int64. The Tensor is a prefix sum of the number of neighbors for each query point.

◆ HybridIndex()

bool open3d::core::nns::NearestNeighborSearch::HybridIndex ( utility::optional< double > radius = {})

Set index for hybrid search.

Returns
Returns true if building index success, otherwise false.

◆ HybridSearch()

std::tuple< Tensor, Tensor, Tensor > open3d::core::nns::NearestNeighborSearch::HybridSearch ( const Tensor & query_points,
const double radius,
const int max_knn ) const

Perform hybrid search.

Parameters
query_pointsData points for querying. Must be 2D, with shape {n, d}.
radiusRadius.
max_knnMaximum number of neighbor to search per query.
Returns
Tuple of Tensors, (indices, distances, counts):
  • indices: Tensor of shape {n, knn}, with dtype same as index_dtype_.
  • distances: Tensor of shape {n, knn}, with same dtype with query_points. The distances are squared L2 distances.
  • counts: Counts of neighbour for each query points. [Tensor of shape {n}, with dtype same as index_dtype_].

◆ KnnIndex()

bool open3d::core::nns::NearestNeighborSearch::KnnIndex ( )

Set index for knn search.

Returns
Returns true if building index success, otherwise false.

◆ KnnSearch()

std::pair< Tensor, Tensor > open3d::core::nns::NearestNeighborSearch::KnnSearch ( const Tensor & query_points,
int knn )

Perform knn search.

Parameters
query_pointsQuery points. Must be 2D, with shape {n, d}.
knnNumber of neighbors to search per query point.
Returns
Pair of Tensors, (indices, distances):
  • indices: Tensor of shape {n, knn}, with dtype same as index_dtype_.
  • distances: Tensor of shape {n, knn}, same dtype with query_points. The distances are squared L2 distances.

◆ MultiRadiusIndex()

bool open3d::core::nns::NearestNeighborSearch::MultiRadiusIndex ( )

Set index for multi-radius search.

Returns
Returns true if building index success, otherwise false.

◆ MultiRadiusSearch()

std::tuple< Tensor, Tensor, Tensor > open3d::core::nns::NearestNeighborSearch::MultiRadiusSearch ( const Tensor & query_points,
const Tensor & radii )

Perform multi-radius search. Each query point has an independent radius.

Parameters
query_pointsQuery points. Must be 2D, with shape {n, d}.
radiiRadii of query points. Each query point has one radius. Must be 1D, with shape {n,}.
Returns
Tuple of Tensors, (indices,distances, num_neighbors):
  • indices: Tensor of shape {total_number_of_neighbors,}, with dtype same as index_dtype_.
  • distances: Tensor of shape {total_number_of_neighbors,}, same dtype with query_points. The distances are squared L2 distances.
  • num_neighbors: Tensor of shape {n+1,}, with dtype Int64. The Tensor is a prefix sum of the number of neighbors for each query point.

◆ operator=()

NearestNeighborSearch & open3d::core::nns::NearestNeighborSearch::operator= ( const NearestNeighborSearch & )
delete

Field Documentation

◆ dataset_points_

const Tensor open3d::core::nns::NearestNeighborSearch::dataset_points_
protected

◆ fixed_radius_index_

std::unique_ptr<nns::FixedRadiusIndex> open3d::core::nns::NearestNeighborSearch::fixed_radius_index_
protected

◆ index_dtype_

const Dtype open3d::core::nns::NearestNeighborSearch::index_dtype_
protected

◆ knn_index_

std::unique_ptr<nns::KnnIndex> open3d::core::nns::NearestNeighborSearch::knn_index_
protected

◆ nanoflann_index_

std::unique_ptr<NanoFlannIndex> open3d::core::nns::NearestNeighborSearch::nanoflann_index_
protected

The documentation for this class was generated from the following files: