octree
Octree construction, interpolation, and upsampling helpers built on ocnn.
Functions:
-
build_octreeβBuild an
ocnn.octree.Octreefrom a packed point cloud. -
octree_interpolateβFunctional interface for
ocnn.nn.OctreeInterp, for ease of use. -
octree_upsampleβUpsample octree features from
src_depthto the finerdst_depth.
build_octree [source] ΒΆ
build_octree(
pos: Tensor,
normal: OptTensor = None,
x: OptTensor = None,
batch: OptTensor = None,
labels: OptTensor = None,
depth: int = 11,
full_depth: int = 2,
batch_size: int = 1,
*,
return_points: bool = False,
) -> Octree | tuple[Octree, Points]
Build an ocnn.octree.Octree from a packed point cloud.
Wraps ocnn.octree.Points construction and Octree.build_octree. Coordinates are expected in the ocnn convention, i.e. normalized to \([-1, 1]\).
Parameters:
-
pos(Tensor) βPoint coordinates of shape \((N, 3)\), normalized to \([-1, 1]\).
-
normal(OptTensor, default:None) βOptional per-point normals of shape \((N, 3)\).
-
x(OptTensor, default:None) βOptional per-point features of shape \((N, C)\).
-
batch(OptTensor, default:None) βOptional per-point batch indices of shape \((N,)\);
Nonefor a single sample. -
labels(OptTensor, default:None) βOptional per-point labels of shape \((N,)\).
-
depth(int, default:11) βDepth of the octree.
-
full_depth(int, default:2) βDepth up to which all octree nodes are kept, empty or not.
-
batch_size(int, default:1) βNumber of samples in the batch.
-
return_points(bool, default:False) βIf
True, also return the intermediateocnn.octree.Pointsobject.
Returns:
-
Octree | tuple[Octree, Points]βThe octree, or the tuple
(octree, points)whenreturn_pointsisTrue.
octree_interpolate [source] ΒΆ
octree_interpolate(
x: Tensor,
octree: Octree,
depth: int,
pts: Tensor,
method: Literal["linear", "nearest"] = "linear",
nempty: bool = False,
bound_check: bool = False,
rescale_pts: bool = True,
) -> Tensor
Functional interface for ocnn.nn.OctreeInterp, for ease of use. This function will interpolate the points with an octree feature.
Note
In comparison to the original ocnn.nn.OctreeInterp, this function signature expects (x, pos, octree, depth) instead of (x, octree, depth, pos), to be consistent with other functions and the design philosophy of this library.
Parameters:
-
x(Tensor) βThe octree features to interpolate, of shape \((M, C)\) with \(M\) the number of octree nodes at
depth. -
octree(Octree) βThe octree structure.
-
depth(int) βThe depth of the octree.
-
pts(Tensor) βThe points to interpolate at, of shape \((N, 4)\) in the format \((x, y, z, \text{batch})\). The input is not modified.
-
method(Literal['linear', 'nearest'], default:'linear') βThe method to use for interpolation,
"linear"or"nearest". -
nempty(bool, default:False) βWhether the features
xonly cover non-empty octree nodes. -
bound_check(bool, default:False) βWhether to check if the points are within the bounds of the octree.
-
rescale_pts(bool, default:True) βWhether to rescale the point coordinates from \([-1, 1]\) to \([0, 2^\text{depth}]\).
Returns:
-
TensorβThe interpolated features of shape \((N, C)\).
octree_upsample [source] ΒΆ
octree_upsample(
x: Tensor,
octree: Octree,
src_depth: int,
dst_depth: int,
method: Literal["linear", "nearest"] = "linear",
nempty: bool = False,
) -> Tensor
Upsample octree features from src_depth to the finer dst_depth.
Interpolates the features of the octree nodes at src_depth at the node centers of dst_depth. When dst_depth == src_depth the features are returned unchanged; a single-level nearest upsample uses the dedicated ocnn kernel.
Parameters:
-
x(Tensor) βThe octree features at
src_depth, of shape \((M_\text{src}, C)\). -
octree(Octree) βThe octree structure.
-
src_depth(int) βThe depth the features live at.
-
dst_depth(int) βThe target depth; must be greater than or equal to
src_depth. -
method(Literal['linear', 'nearest'], default:'linear') βThe method to use for interpolation,
"linear"or"nearest". -
nempty(bool, default:False) βWhether the features
xonly cover non-empty octree nodes.
Returns:
-
TensorβThe upsampled features of shape \((M_\text{dst}, C)\).