py123detection.mmcv_export.converter

123D scenes -> mmdetection3d info dicts, one per frame.

The reference frame is the keyframe’s lidar frame, as in mmdet3d. 123D stores everything in the global frame, so each frame composes lidar -> ego -> global from the ego state and rig extrinsics and inverts it. See py123detection.mmcv_export.schema for the fields.

Module Attributes

DEFAULT_CAMERA_ORDER

123D camera ids.

Classes

ExportConfig([taxonomy, camera_order, ...])

Everything that shapes an export, independent of which scenes are exported.

ExportStats([num_logs, num_frames, ...])

MMDet3DConverter([config])

py123detection.mmcv_export.converter.DEFAULT_CAMERA_ORDER: Tuple[str, ...] = ('PCAM_F0', 'PCAM_R0', 'PCAM_L0', 'PCAM_B0', 'PCAM_L1', 'PCAM_R1')

123D camera ids. On a nuScenes rig this is CAM_FRONT, CAM_FRONT_RIGHT, CAM_FRONT_LEFT, CAM_BACK, CAM_BACK_LEFT, CAM_BACK_RIGHT, the order mmdetection3d’s converter uses and pretrained multi-view models expect.

class py123detection.mmcv_export.converter.ExportConfig(taxonomy=Taxonomy(name='nuscenes_detection_10cls'), camera_order=('PCAM_F0', 'PCAM_R0', 'PCAM_L0', 'PCAM_B0', 'PCAM_L1', 'PCAM_R1'), camera_key='native', reference_lidar=None, max_sweeps=10, with_2d_annotations=True, on_missing_camera='skip_frame', sensors=<factory>, token_resolver=<factory>, include_track_tokens=True, yaw_convention='mmdet3d', lidar2ego_mode='static', camera2ego_mode='static', lidar_frame='sensor', planar_velocity=True, box_layout='streampetr', velocity_source='stored', velocity_max_dt_s=0.25, ego_pose_source='sync')[source]

Bases: object

Everything that shapes an export, independent of which scenes are exported.

taxonomy: Taxonomy = Taxonomy(name='nuscenes_detection_10cls')
camera_order: Tuple[str, ...] = ('PCAM_F0', 'PCAM_R0', 'PCAM_L0', 'PCAM_B0', 'PCAM_L1', 'PCAM_R1')

123D CameraID names, in model input order.

camera_key: str = 'native'

Key of each camera in info['cams']: "native" (CAM_FRONT, what stock configs expect) or "camera_id" (PCAM_F0, consistent across datasets in merged exports).

reference_lidar: str | None = None

LidarID name of the reference frame. None picks LIDAR_TOP, else the first lidar.

max_sweeps: int = 10

Preceding lidar frames per info, taken at the log’s own rate rather than the export rate.

A keyframe-only nuScenes conversion only holds 2 Hz lidar, so its sweeps are 2 Hz. The first frame of a log always gets an empty list, which StreamPETR reads as a sequence start.

with_2d_annotations: bool = True

Per-camera 2D / mono-3D annotations, required by StreamPETR.

on_missing_camera: str = 'skip_frame'

"skip_frame" (multi-view models need a fixed camera count), "drop_camera" or "error".

sensors: SensorResolverConfig
token_resolver: TokenResolver
include_track_tokens: bool = True

Also write per-box instance_tokens.

yaw_convention: str = 'mmdet3d'

"mmdet3d" matches pickles from mmdetection3d’s converter, "heading" the nuScenes devkit. See py123detection.geometry.mmdet3d_yaw().

lidar2ego_mode: str = 'static'

"static" writes the rig extrinsic, like mmdetection3d’s converter.

"dynamic" also folds in the ego motion between the frame timestamp and the lidar’s own timestamp: inv(ego2global_at_frame) @ ego2global_at_lidar_time @ lidar2ego_static. 123D stores no per-row lidar pose, so this only differs from static when the ego stream is denser than the frames (not for keyframe-only nuScenes).

camera2ego_mode: str = 'static'

Where a camera’s timing offset to the frame is booked.

"static" keeps sensor2ego at the rig calibration and moves ego2global to the camera timestamp, like mmdetection3d. "dynamic" keeps the frame’s ego2global and folds the offset into sensor2ego. sensor2lidar, which PETR and StreamPETR use, is the same either way; BEVDet-style configs read the two parts separately.

lidar_frame: str = 'sensor'

"sensor" uses the reference lidar’s frame (mmdet3d’s convention, and the frame of a referenced point cloud file). "ego" uses the ego/IMU frame, so lidar2ego is the identity.

planar_velocity: bool = True

Drop the global vertical velocity before rotating into the lidar frame. mmdetection3d does this and its evaluation assumes it.

box_layout: str = 'streampetr'

gt_boxes column layout, see py123detection.annotations.BOX_LAYOUTS. A wrong choice does not crash, it trains on transposed, mis-rotated boxes.

velocity_source: str = 'stored'

"stored" uses the log’s velocity (zero if the dataset has none). "tracks" derives it from neighbouring annotations of each track, see py123detection.velocity.

velocity_max_dt_s: float = 0.25
ego_pose_source: str = 'sync'

Which ego state gives a frame’s ego2global: the sync table row ("sync") or the state nearest to the frame timestamp ("nearest").

The sync table takes the first ego row at or after the frame timestamp, so an ego timestamp that is 1 us early skips the right row. py123d 0.6.0’s Argoverse 2 parser round-trips the nanosecond stamps through float64: 5% of ego rows come back 1 us early and ~40% of frames get an ego pose 2-10 ms late (up to 9 cm). "nearest" avoids that.

class py123detection.mmcv_export.converter.ExportStats(num_logs=0, num_frames=0, num_boxes=0, frames_skipped_missing_camera=0, frames_skipped_missing_ego=0, frames_skipped_missing_lidar=0, logs_skipped=0, dynamic_extrinsic_fallbacks=0, boxes_without_track_velocity=0, ego_pose_fallbacks=0, ego_pose_max_offset_us=0, dropped_cameras=<factory>, class_counts=<factory>, num_referenced_payloads=0, num_extracted_payloads=0)[source]

Bases: object

num_logs: int = 0
num_frames: int = 0
num_boxes: int = 0
frames_skipped_missing_camera: int = 0
frames_skipped_missing_ego: int = 0
frames_skipped_missing_lidar: int = 0
logs_skipped: int = 0
dynamic_extrinsic_fallbacks: int = 0
boxes_without_track_velocity: int = 0
ego_pose_fallbacks: int = 0
ego_pose_max_offset_us: int = 0
dropped_cameras: Counter
class_counts: Counter
num_referenced_payloads: int = 0
num_extracted_payloads: int = 0
as_dict()[source]
Return type:

Dict[str, Any]

class py123detection.mmcv_export.converter.MMDet3DConverter(config=None)[source]

Bases: object

property stats: ExportStats
convert_scenes(scenes, timestamp_offset_us=0, progress=True, native_scenes=None)[source]

Convert scenes (one per log) into a flat list of infos.

Parameters:

native_scenes (Optional[Dict[Tuple[str, str], SceneAPI]]) – Native-rate views of the same logs by (split, log_name), needed for sweeps and track velocities when scenes are subsampled.

Return type:

List[Dict[str, Any]]

convert_scene(scene, timestamp_offset_us=0, native_scene=None)[source]

Convert one full log into infos, in frame order.

Parameters:

native_scene (Optional[SceneAPI]) – Native-rate view of the log, for sweeps and velocity_source="tracks". Omit when scene is not subsampled.

Return type:

List[Dict[str, Any]]