pymomentum.skel_state
- pymomentum.skel_state.blend(skel_states: Tensor, weights: Tensor | None = None) Tensor
Blend k skeleton states with the passed-in weights.
- Parameters:
skel_states (torch.Tensor) – The skeleton states to blend.
weights – The weights to use, if not provided, weights are assumed to be all 1s
- Returns:
The blended skeleton state.
- pymomentum.skel_state.check(skel_state: Tensor) None
Check if the skeleton state has the correct shape.
- Parameters:
skel_state (torch.Tensor) – The skeleton state to check.
- Raises:
ValueError – If the skeleton state does not have the correct shape.
- pymomentum.skel_state.from_matrix(matrices: Tensor) Tensor
Convert 4x4 matrices to skeleton states. Assumes that the scale is uniform.
- Args:
matrices (torch.Tensor): A tensor of 4x4 matrices.
- Returns:
torch.Tensor: The corresponding skeleton states.
- pymomentum.skel_state.from_quaternion(rotation: Tensor) Tensor
Create a skeleton state from rotation.
- Parameters:
rotation (torch.Tensor) – The rotation component.
- Returns:
The skeleton state.
- Return type:
torch.Tensor
- pymomentum.skel_state.from_scale(scale: Tensor) Tensor
Create a skeleton state from scale.
- Parameters:
scale (torch.Tensor) – The scale component.
- Returns:
The skeleton state.
- Return type:
torch.Tensor
- pymomentum.skel_state.from_translation(translation: Tensor) Tensor
Create a skeleton state from translation.
- Parameters:
translation (torch.Tensor) – The translation component.
- Returns:
The skeleton state.
- Return type:
torch.Tensor
- pymomentum.skel_state.identity(size: Sequence[int] | None = None, device: device | None = None) Tensor
Returns a skeleton state representing the identity transform.
- Parameters:
sizes (list[int], optional) – The size of each dimension in the output tensor. Defaults to None, which means the output will be a 1D tensor with 8 elements.
device (torch.device, optional) – The device on which to create the tensor. Defaults to None, which means the tensor will be created on the default device.
- Returns:
The identity skeleton state.
- Return type:
torch.Tensor
- pymomentum.skel_state.inverse(skeleton_states: Tensor) Tensor
Compute the inverse of a skeleton state.
- Parameters:
skeleton_states (torch.Tensor) – The skeleton state to invert.
- Returns:
The inverted skeleton state.
- Return type:
torch.Tensor
- pymomentum.skel_state.match_leading_dimensions(t_left: Tensor, t_right: Tensor) Tensor
Match the leading dimensions of two tensors.
- Parameters:
t_left (torch.Tensor) – The first tensor.
t_right (torch.Tensor) – The second tensor.
- Returns:
The first tensor with its leading dimensions matched to the second tensor.
- Return type:
torch.Tensor
- pymomentum.skel_state.multiply(s1: Tensor, s2: Tensor) Tensor
Multiply two skeleton states.
- Parameters:
s1 (torch.Tensor) – The first skeleton state.
s2 (torch.Tensor) – The second skeleton state.
- Returns:
The product of the two skeleton states.
- Return type:
torch.Tensor
- pymomentum.skel_state.split(skel_state: Tensor) tuple[Tensor, Tensor, Tensor]
Split a skeleton state into translation, rotation, and scale components.
- Parameters:
skel_state (torch.Tensor) – The skeleton state to split.
- Returns:
A tuple of tensors (translation, rotation, scale).
- Return type:
tuple[torch.Tensor, torch.Tensor, torch.Tensor]
- pymomentum.skel_state.to_matrix(skeleton_state: Tensor) Tensor
Convert skeleton state to a tensor of 4x4 matrices. The matrix represents the transform from a local joint space to the world space.
- Parameters:
skeleton_state (torch.Tensor) – The skeleton state to convert.
- Returns:
A tensor containing 4x4 matrix transforms.
- Return type:
torch.Tensor
- pymomentum.skel_state.transform_points(skel_state: Tensor, points: Tensor) Tensor
Transform 3d points by the transform represented by the skeleton state.
- Parameters:
skel_state (torch.Tensor) – The skeleton state to use for transformation.
points (torch.Tensor) – The points to transform.
- Returns:
The transformed points.
- Return type:
torch.Tensor