open3d.ml.tf.layers.FixedRadiusSearch

class open3d.ml.tf.layers.FixedRadiusSearch(*args, **kwargs)

Fixed radius search for 3D point clouds.

This layer computes the neighbors for a fixed radius on a point cloud.

Example

This example shows a neighbor search that returns the indices to the found neighbors and the distances.:

import tensorflow as tf
import open3d.ml.tf as ml3d

points = tf.random.normal([20,3])
queries = tf.random.normal([10,3])
radius = 0.8

nsearch = ml3d.layers.FixedRadiusSearch(return_distances=True)
ans = nsearch(points, queries, radius)
# returns a tuple of neighbors_index, neighbors_row_splits, and neighbors_distance
Parameters
  • metric – Either L1, L2 or Linf. Default is L2.

  • ignore_query_point – If True the points that coincide with the center of the search window will be ignored. This excludes the query point if ‘queries’ and ‘points’ are the same point cloud.

  • return_distances – If True the distances for each neighbor will be returned. If False a zero length Tensor will be returned instead.

__init__(metric='L2', ignore_query_point=False, return_distances=False, max_hash_table_size=33554432, **kwargs)
build(inp_shape)

Creates the variables of the layer (optional, for subclass implementers).

This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call.

This is typically used to create the weights of Layer subclasses.

Parameters

input_shape – Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).

call(points, queries, radius, points_row_splits=None, queries_row_splits=None, hash_table_size_factor=0.015625, hash_table=None)

This function computes the neighbors within a fixed radius for each query point.

Parameters
  • points – The 3D positions of the input points. This argument must be given as a positional argument!

  • queries – The 3D positions of the query points.

  • radius – A scalar with the neighborhood radius

  • points_row_splits – Optional 1D vector with the row splits information if points is batched. This vector is [0, num_points] if there is only 1 batch item.

  • queries_row_splits – Optional 1D vector with the row splits information if queries is batched. This vector is [0, num_queries] if there is only 1 batch item.

  • hash_table_size_factor – Scalar. The size of the hash table as fraction of points.

  • hash_table – A precomputed hash table generated with build_spatial_hash_table(). This input can be used to explicitly force the reuse of a hash table in special cases and is usually not needed. Note that the hash table must have been generated with the same ‘points’ array.

Returns

3 Tensors in the following order

neighbors_index

The compact list of indices of the neighbors. The corresponding query point can be inferred from the ‘neighbor_count_row_splits’ vector.

neighbors_row_splits

The exclusive prefix sum of the neighbor count for the query points including the total neighbor count as the last element. The size of this array is the number of queries + 1.

neighbors_distance

Stores the distance to each neighbor if ‘return_distances’ is True. Note that the distances are squared if metric is L2. This is a zero length Tensor if ‘return_distances’ is False.