open3d.ml.tf.models.build_spatial_hash_table¶
-
open3d.ml.tf.models.
build_spatial_hash_table
(points, radius, points_row_splits, hash_table_size_factor, max_hash_table_size=33554432, name=None)¶ Creates a spatial hash table meant as input for fixed_radius_search
The following example shows how build_spatial_hash_table and fixed_radius_search are used together:
import open3d.ml.tf as ml3d points = [ [0.1,0.1,0.1], [0.5,0.5,0.5], [1.7,1.7,1.7], [1.8,1.8,1.8], [0.3,2.4,1.4]] queries = [ [1.0,1.0,1.0], [0.5,2.0,2.0], [0.5,2.1,2.1], ] radius = 1.0 # build the spatial hash table for fixex_radius_search table = ml3d.ops.build_spatial_hash_table(points, radius, points_row_splits=torch.LongTensor([0,5]), hash_table_size_factor=1/32) # now run the fixed radius search ml3d.ops.fixed_radius_search(points, queries, radius, points_row_splits=torch.LongTensor([0,5]), queries_row_splits=torch.LongTensor([0,3]), **table._asdict()) # returns neighbors_index = [1, 4, 4] # neighbors_row_splits = [0, 1, 2, 3] # neighbors_distance = [] # or with pytorch import torch import open3d.ml.torch as ml3d points = torch.Tensor([ [0.1,0.1,0.1], [0.5,0.5,0.5], [1.7,1.7,1.7], [1.8,1.8,1.8], [0.3,2.4,1.4]]) queries = torch.Tensor([ [1.0,1.0,1.0], [0.5,2.0,2.0], [0.5,2.1,2.1], ]) radius = 1.0 # build the spatial hash table for fixex_radius_search table = ml3d.ops.build_spatial_hash_table(points, radius, points_row_splits=torch.LongTensor([0,5]), hash_table_size_factor=1/32) # now run the fixed radius search ml3d.ops.fixed_radius_search(points, queries, radius, points_row_splits=torch.LongTensor([0,5]), queries_row_splits=torch.LongTensor([0,3]), **table._asdict()) # returns neighbors_index = [1, 4, 4] # neighbors_row_splits = [0, 1, 2, 3] # neighbors_distance = []
- Parameters
points – A Tensor. Must be one of the following types: float32, float64. The 3D positions of the input points.
radius – A Tensor. Must have the same type as points. A scalar which defines the spatial cell size of the hash table.
points_row_splits – A Tensor of type int64. 1D vector with the row splits information if points is batched. This vector is [0, num_points] if there is only 1 batch item.
hash_table_size_factor – A Tensor of type float64. The size of the hash table as a factor of the number of input points.
max_hash_table_size – An optional int. Defaults to 33554432. The maximum hash table size.
name – A name for the operation (optional).
- Returns
A tuple of Tensor objects (hash_table_index, hash_table_cell_splits, hash_table_splits).
- hash_table_index: A Tensor of type uint32. Stores the values of the hash table, which are the indices of
the points. The start and end of each cell is defined by hash_table_cell_splits.
- hash_table_cell_splits: A Tensor of type uint32. Defines the start and end of each hash table cell within
a hash table.
- hash_table_splits: A Tensor of type uint32. Defines the start and end of each hash table in the
hash_table_cell_splits array. If the batch size is 1 then there is only one hash table and this vector is [0, number of cells].