pose_format.utils.normalization_3d module
Classes:
|
Class to normalize pose using normalization information. |
- class pose_format.utils.normalization_3d.PoseNormalizer(plane, line, size=1)[source]
Bases:
objectClass to normalize pose using normalization information.
- Parameters:
plane (PoseNormalizationInfo) – Plane normalization information
line (PoseNormalizationInfo) – Line normalization information
size (float) – The desired size after normalization, defaults to 1
Methods:
get_normal(pose)Get normal vector based on pose "plane"
get_rotation_angle(pose)Gets rotation angle required to rotate pose such that the line is on the Y axis.
normalize_pose(pose)Fully normalizes the pose - rotates to match normals, then rotates in the X-Y plane, and finally scales.
rotate(pose, angle)Rotate pose in the X-Y plane by a custom angle (np.ndarray).
rotate_to_normal(pose, normal, around)Rotate pose so that its normal vector aligns with z-axis.
scale(pose)Scaling of pose
- get_normal(pose)[source]
Get normal vector based on pose “plane”
- Parameters:
pose (ma.masked_array) – Pose data.
- Returns:
normal (ma.masked_array) – Normal vector for pose.
base (ma.masked_array) – Base point -> triangle[:,0] used to compute normal
- Return type:
Tuple[MaskedArray, MaskedArray]
Note
Important that plane attributes (p1, p2, p3) are correctly initialized for normal to be correctly computed
- get_rotation_angle(pose)[source]
Gets rotation angle required to rotate pose such that the line is on the Y axis.
- Parameters:
pose (ma.masked_array) – Pose data
- Returns:
Angles (degrees) needed for each pose in the array
- Return type:
ma.masked_array
- normalize_pose(pose)[source]
Fully normalizes the pose - rotates to match normals, then rotates in the X-Y plane, and finally scales.
- Parameters:
pose (ma.masked_array) – original pose data
- Returns:
fully normalized pose
- Return type:
ma.masked_array
- rotate(pose, angle)[source]
Rotate pose in the X-Y plane by a custom angle (np.ndarray).
- Parameters:
pose (ma.masked_array) – Original pose data
angle (np.ndarray) – Angles to rotate poses, in degrees.
- Returns:
rotated pose
- Return type:
ma.masked_array
- rotate_to_normal(pose, normal, around)[source]
Rotate pose so that its normal vector aligns with z-axis.
- Parameters:
pose (ma.masked_array) – Original pose data
normal (ma.masked_array) – Normal vector with respect to which the pose will be aligned.
around (ma.masked_array) – Points to rotate around
- Returns:
The rotated pose
- Return type:
ma.masked_array
- Raises:
ValueError: – if the shapes of pose, normal, and around aren’t compatible.
Examples
>>> pose = ma.masked_array([[1, 1], [2, 2], [3, 3]]) >>> normal = ma.masked_array([0, 0, 1]) >>> around = ma.masked_array([1, 1]) >>> rotated_pose = normalizer.rotate_to_normal(pose, normal, around)