Open3D (C++ API)  0.17.0
Namespaces | Data Structures | Enumerations | Functions
open3d::core::nns Namespace Reference

Namespaces

 impl
 

Data Structures

class  FixedRadiusIndex
 FixedRadiusIndex for nearest neighbor range search. More...
 
class  KnnIndex
 
class  MemoryAllocation
 A class for managing memory segments within a memory allocation. More...
 
struct  NanoFlannIndexHolder
 NanoFlann Index Holder. More...
 
class  NanoFlannIndex
 
class  NearestNeighborSearch
 A Class for nearest neighbor search. More...
 
class  NeighborSearchAllocator
 
struct  NanoFlannIndexHolderBase
 Base struct for NanoFlann index holder. More...
 
class  NNSIndex
 

Enumerations

enum  Metric { L1 , L2 , Linf }
 Supported metrics. More...
 

Functions

template<class T >
void BuildSpatialHashTableCPU (const Tensor &points, double radius, const Tensor &points_row_splits, const Tensor &hash_table_splits, Tensor &hash_table_index, Tensor &hash_table_cell_splits)
 
template<class T , class TIndex >
void FixedRadiusSearchCPU (const Tensor &points, const Tensor &queries, double radius, const Tensor &points_row_splits, const Tensor &queries_row_splits, const Tensor &hash_table_splits, const Tensor &hash_table_index, const Tensor &hash_table_cell_splits, const Metric metric, const bool ignore_query_point, const bool return_distances, const bool sort, Tensor &neighbors_index, Tensor &neighbors_row_splits, Tensor &neighbors_distance)
 
template<class T , class TIndex >
void HybridSearchCPU (const Tensor &points, const Tensor &queries, double radius, int max_knn, const Tensor &points_row_splits, const Tensor &queries_row_splits, const Tensor &hash_table_splits, const Tensor &hash_table_index, const Tensor &hash_table_cell_splits, const Metric metric, Tensor &neighbors_index, Tensor &neighbors_count, Tensor &neighbors_distance)
 
HOST_DEVICE size_t SpatialHash (int x, int y, int z)
 Spatial hashing function for integer coordinates. More...
 
HOST_DEVICE size_t SpatialHash (const utility::MiniVec< int, 3 > &xyz)
 
template<class TVecf >
HOST_DEVICE utility::MiniVec< int, 3 > ComputeVoxelIndex (const TVecf &pos, const typename TVecf::Scalar_t &inv_voxel_size)
 

Enumeration Type Documentation

◆ Metric

Supported metrics.

Enumerator
L1 
L2 
Linf 

Function Documentation

◆ BuildSpatialHashTableCPU()

template<class T >
void open3d::core::nns::BuildSpatialHashTableCPU ( const Tensor points,
double  radius,
const Tensor points_row_splits,
const Tensor hash_table_splits,
Tensor hash_table_index,
Tensor hash_table_cell_splits 
)

Builds a spatial hash table for a fixed radius search of 3D points.

Template Parameters
TFloating-point data type for the point positions.
Parameters
pointsThe tensor of 3D points. This tensor may be splitted into multiple batch items by defining points_row_splits_size accordingly.
radiusThe radius that will be used for searching.
points_row_splitsDefines the start and end of the points in each batch item. The size of the tensor is batch_size+1. If there is only 1 batch item then this array is [0, num_points]
hash_table_splitsTensor defining the start and end the hash table for each batch item. This is [0, number of cells] if there is only 1 batch item or [0, hash_table_cell_splits_size-1] which is the same.
hash_table_indexThis is an output tensor storing the values of the hash table, which are the indices to the points. The size of the tensor must be equal to the number of points.
hash_table_cell_splitsThis is an output tensor storing the start of each hash table entry. The size of this array defines the size of the hash table. The hash table size is hash_table_cell_splits_size - 1.

◆ ComputeVoxelIndex()

template<class TVecf >
HOST_DEVICE utility::MiniVec<int, 3> open3d::core::nns::ComputeVoxelIndex ( const TVecf &  pos,
const typename TVecf::Scalar_t &  inv_voxel_size 
)
inline

Computes an integer voxel index for a 3D position.

Parameters
posA 3D position.
inv_voxel_sizeThe reciprocal of the voxel size

◆ FixedRadiusSearchCPU()

template<class T , class TIndex >
void open3d::core::nns::FixedRadiusSearchCPU ( const Tensor points,
const Tensor queries,
double  radius,
const Tensor points_row_splits,
const Tensor queries_row_splits,
const Tensor hash_table_splits,
const Tensor hash_table_index,
const Tensor hash_table_cell_splits,
const Metric  metric,
const bool  ignore_query_point,
const bool  return_distances,
const bool  sort,
Tensor neighbors_index,
Tensor neighbors_row_splits,
Tensor neighbors_distance 
)

Fixed radius search. This function computes a list of neighbor indices for each query point. The lists are stored linearly and an exclusive prefix sum defines the start and end of list in the array. In addition the function optionally can return the distances for each neighbor in the same format as the indices to the neighbors.

Template Parameters
TFloating-point data type for the point positions.
Parameters
pointsTensor with the 3D point positions. This must be the tensor that was used for building the spatial hash table.
queriesTensor with the 3D query positions. This may be the same tensor as points.
radiusThe search radius.
points_row_splitsDefines the start and end of the points in each batch item. The size of the tensor is batch_size+1. If there is only 1 batch item then this tensor is [0, num_points]
queries_row_splitsDefines the start and end of the queries in each batch item. The size of the tensor is batch_size+1. If there is only 1 batch item then this tensor is [0, num_queries]
hash_table_splitsTensor defining the start and end the hash table for each batch item. This is [0, number of cells] if there is only 1 batch item or [0, hash_table_cell_splits_size-1] which is the same.
hash_table_indexThis is an output of the function BuildSpatialHashTableCPU. This is tensor storing the values of the hash table, which are the indices to the points. The size of the tensor must be equal to the number of points.
hash_table_cell_splitsThis is an output of the function BuildSpatialHashTableCPU. The row splits array describing the start and end of each cell.
metricOne of L1, L2, Linf. Defines the distance metric for the search.
ignore_query_pointIf true then points with the same position as the query point will be ignored.
return_distancesIf true then this function will return the distances for each neighbor to its query point in the same format as the indices. Note that for the L2 metric the squared distances will be returned!!
sortIf true then sort the results in ascending order of distance
neighbors_indexThe output tensor that saves the resulting neighbor indices
neighbors_row_splitsTensor defining the start and end the neighbor indices in each batch item. The size of the tensor is num_query_points + 1
neighbors_distanceThe output tensor that saves the resulting neighbor distances.

◆ HybridSearchCPU()

template<class T , class TIndex >
void open3d::core::nns::HybridSearchCPU ( const Tensor points,
const Tensor queries,
double  radius,
int  max_knn,
const Tensor points_row_splits,
const Tensor queries_row_splits,
const Tensor hash_table_splits,
const Tensor hash_table_index,
const Tensor hash_table_cell_splits,
const Metric  metric,
Tensor neighbors_index,
Tensor neighbors_count,
Tensor neighbors_distance 
)

Hybrid search. This function computes a list of neighbor indices for each query point. The lists are stored linearly and if there is less neighbors than requested, the output tensor will be assigned with default values, -1 for indices and 0 for distances. In addition the function returns the number of neighbors for each query.

Template Parameters
TFloating-point data type for the point positions.
Parameters
pointsTensor with the 3D point positions. This must be the tensor that was used for building the spatial hash table.
queriesTensor with the 3D query positions. This may be the same tensor as points.
radiusThe search radius.
max_knnThe maximum number of neighbor for each query
points_row_splitsDefines the start and end of the points in each batch item. The size of the tensor is batch_size+1. If there is only 1 batch item then this tensor is [0, num_points]
queries_row_splitsDefines the start and end of the queries in each batch item. The size of the tensor is batch_size+1. If there is only 1 batch item then this tensor is [0, num_queries]
hash_table_splitsTensor defining the start and end the hash table for each batch item. This is [0, number of cells] if there is only 1 batch item or [0, hash_table_cell_splits_size-1] which is the same.
hash_table_indexThis is an output of the function BuildSpatialHashTableCPU. This is tensor storing the values of the hash table, which are the indices to the points. The size of the tensor must be equal to the number of points.
hash_table_cell_splitsThis is an output of the function BuildSpatialHashTableCPU. The row splits array describing the start and end of each cell.
metricOne of L1, L2, Linf. Defines the distance metric for the search.
neighbors_indexThe output tensor that saves the resulting neighbor indices
neighbors_countThe output tensor that saves the number of neighbors for each query points
neighbors_distanceThe output tensor that saves the resulting neighbor distances.

◆ SpatialHash() [1/2]

HOST_DEVICE size_t open3d::core::nns::SpatialHash ( const utility::MiniVec< int, 3 > &  xyz)
inline

◆ SpatialHash() [2/2]

HOST_DEVICE size_t open3d::core::nns::SpatialHash ( int  x,
int  y,
int  z 
)
inline

Spatial hashing function for integer coordinates.