py123d_detection.core.annotations

Per-frame 3D annotations in mmdetection3d’s nuScenes layout.

123D stores boxes in the global frame, mmdet3d wants them in the keyframe’s lidar frame: gt_boxes (N, 7) as [x, y, z, l, w, h, yaw] around the box center (mmdet3d moves the origin to the bottom face at load time) and gt_velocity (N, 2).

Module Attributes

BOX_LAYOUTS

"streampetr": [x, y, z, l, w, h, yaw], written and read by StreamPETR and mmdetection3d >= 1.0.

Functions

apply_merge_rules(records, taxonomy)

Combine riders with their vehicles, and drop what is left merge-only.

build_frame_annotations(records, global_to_lidar)

Move global-frame records into the lidar frame and build the mmdet3d arrays.

extract_detection_records(detections, taxonomy)

Map 123D detections onto taxonomy classes, dropping unmapped ones.

Classes

DetectionRecord(class_name, label_id, ...)

One annotated object, in the global frame.

FrameAnnotations(gt_boxes, gt_names, ...)

The 3D annotation block of one info, in the lidar frame.

py123d_detection.core.annotations.BOX_LAYOUTS = ('streampetr', 'mmdet3d_0.17')

“streampetr”: [x, y, z, l, w, h, yaw], written and read by StreamPETR and mmdetection3d >= 1.0. “mmdet3d_0.17”: [x, y, z, w, l, h, -yaw - pi/2], written by mmdetection3d 0.17’s nuScenes converter and fed verbatim into LiDARInstance3DBoxes by its dataset (PETR v1 pins 0.17).

class py123d_detection.core.annotations.DetectionRecord(class_name, label_id, center_global, rotation_global, size_lwh, velocity_global, num_lidar_points, track_token, corners_global)[source]

Bases: object

One annotated object, in the global frame.

class_name: str
label_id: int
center_global: ndarray
rotation_global: ndarray
size_lwh: ndarray
velocity_global: ndarray
num_lidar_points: int
track_token: str
corners_global: ndarray
class py123d_detection.core.annotations.FrameAnnotations(gt_boxes, gt_names, gt_velocity, num_lidar_pts, num_radar_pts, valid_flag, track_tokens, records)[source]

Bases: object

The 3D annotation block of one info, in the lidar frame.

gt_boxes: ndarray
gt_names: ndarray
gt_velocity: ndarray
num_lidar_pts: ndarray
num_radar_pts: ndarray
valid_flag: ndarray
track_tokens: List[str]
records: List[DetectionRecord]
py123d_detection.core.annotations.apply_merge_rules(records, taxonomy)[source]

Combine riders with their vehicles, and drop what is left merge-only.

Each secondary takes the free primary of the same rule it overlaps most, so a scene with two cyclists side by side pairs each rider with their own bicycle rather than both with one. Records not named by any rule pass through first and in order; merged ones follow.

Return type:

List[DetectionRecord]

py123d_detection.core.annotations.extract_detection_records(detections, taxonomy, velocity_overrides=None)[source]

Map 123D detections onto taxonomy classes, dropping unmapped ones.

Parameters:

velocity_overrides (Optional[Mapping[str, ndarray]]) – Global-frame velocities by track token (see py123d_detection.core.velocity.TrackVelocityTable). Tracks not in it keep the stored velocity.

Return type:

List[DetectionRecord]

py123d_detection.core.annotations.build_frame_annotations(records, global_to_lidar, yaw_convention='mmdet3d', planar_velocity=True, box_layout='streampetr')[source]

Move global-frame records into the lidar frame and build the mmdet3d arrays.

Parameters:
Return type:

FrameAnnotations