InstanceParser#
- class InstanceParser(segment_ignore_index=(-1, 0, 1), instance_ignore_index=-1, compute_axis_stats=False, axis_min_points=5, axis_eps=1e-06, axis_default=(1.0, 0.0, 0.0), axis_normalize_half_extent=True)[source]#
Bases:
objectCompact instance ids and derive per-instance bounding boxes and centroids.
Reads
data_dict["coord"],data_dict["segment"], anddata_dict["instance"]. Points whose semantic label is insegment_ignore_indexhave their instance set toinstance_ignore_index; remaining instances are relabeled to a dense0..K-1range. Writes back the compactedinstance, a per-pointinstance_centroid(N, 3), and a per-instancebbox(K, 8)(center xyz, size xyz, theta, shifted class). Whencompute_axis_statsis enabled it also runs a per-instance PCA and writes per-pointinstance_axis(N, 3),instance_axis_coord,instance_axis_coord_normalized,instance_axis_length,instance_axis_weight, andinstance_axis_coord_weight. Registered asInstanceParser— use this string as thetypein atransform=[...]config list.- Parameters:
segment_ignore_index (tuple) – Semantic labels excluded from instances; their class indices are also vacated/shifted out of the bbox class. Defaults to
(-1, 0, 1).instance_ignore_index (int) – Instance id assigned to ignored points and used to fill uninitialized centroid/bbox entries. Defaults to
-1.compute_axis_stats (bool) – If
True, compute the per-instance principal-axis statistics. Defaults toFalse.axis_min_points (int) – Minimum points an instance needs for a valid PCA axis (clamped to
>= 1). Defaults to5.axis_eps (float) – Numerical tolerance for axis/eigenvalue validity and normalization. Defaults to
1e-6.axis_default (tuple) – Fallback unit axis (normalized internally, must be non-zero, shape
(3,)) used when PCA is invalid. Defaults to(1.0, 0.0, 0.0).axis_normalize_half_extent (bool) – If
True, normalize the axis coordinate by the half-extent rather than the full extent. Defaults toTrue.
Example
>>> import numpy as np >>> data = { ... "coord": np.array([[0,0,0],[1,0,0],[0,0,0],[5,5,5],[6,5,5]], dtype="f4"), ... "segment": np.array([2, 2, 1, 3, 3]), # class 1 is ignored ... "instance": np.array([10, 10, 7, 20, 20]), ... } >>> out = InstanceParser(segment_ignore_index=(-1, 0, 1))(data) >>> out["instance"] # ignored point -> -1, rest densified 0..K-1 array([ 0, 0, -1, 1, 1]) >>> out["bbox"].shape # (K instances, 8): center xyz, size xyz, theta, class (2, 8)