py123detection.geometry

SE(3) helpers shared by the export code.

123D poses and the mmdet3d info schema both use scalar-first quaternions, so the two map onto each other directly. Everything in between is plain 4x4 matrices.

Module Attributes

YAW_CONVENTIONS

Keyed by ExportConfig.yaw_convention.

Functions

heading_yaw(rotation)

Yaw as the heading of the frame's x axis, the convention of the nuScenes devkit's quaternion_yaw.

invert_rigid(matrix)

Invert a 4x4 rigid transform (no scale or shear) without a general matrix inverse.

matrix_to_translation_quaternion(matrix)

Split a 4x4 transform into the ([x, y, z], [qw, qx, qy, qz]) pair used by mmdet3d infos.

mmdet3d_yaw(rotation)

Yaw as pyquaternion.Quaternion.yaw_pitch_roll[0], which mmdetection3d's converter uses.

pose_to_matrix(pose)

rotate_vectors(matrix, vectors)

transform_points(matrix, points)

py123detection.geometry.pose_to_matrix(pose)[source]
Return type:

ndarray

py123detection.geometry.invert_rigid(matrix)[source]

Invert a 4x4 rigid transform (no scale or shear) without a general matrix inverse.

Return type:

ndarray

py123detection.geometry.matrix_to_translation_quaternion(matrix)[source]

Split a 4x4 transform into the ([x, y, z], [qw, qx, qy, qz]) pair used by mmdet3d infos.

Return type:

Tuple[List[float], List[float]]

py123detection.geometry.transform_points(matrix, points)[source]
Return type:

ndarray

py123detection.geometry.rotate_vectors(matrix, vectors)[source]
Return type:

ndarray

py123detection.geometry.heading_yaw(rotation)[source]

Yaw as the heading of the frame’s x axis, the convention of the nuScenes devkit’s quaternion_yaw.

Return type:

float

py123detection.geometry.mmdet3d_yaw(rotation)[source]

Yaw as pyquaternion.Quaternion.yaw_pitch_roll[0], which mmdetection3d’s converter uses.

pyquaternion computes atan2(2(wz - xy), 1 - 2(y^2 + z^2)) where the textbook z-y-x yaw has +xy. Both agree for an upright box and drift apart with roll/pitch: a few milliradians in a lidar frame, but a large angle in a camera frame where the box lies on its side. Matching it keeps gt_boxes interchangeable with pickles from mmdetection3d’s own converter.

Return type:

float

py123detection.geometry.YAW_CONVENTIONS = {'heading': <function heading_yaw>, 'mmdet3d': <function mmdet3d_yaw>}

Keyed by ExportConfig.yaw_convention.