medusa.recon.flame.lbs
#
Module with functionality for linear blend skinning.
See ./deca/license.md for conditions for use.
Module Contents#
- medusa.recon.flame.lbs.lbs(betas, pose, v_template, shapedirs, posedirs, J_regressor, parents, lbs_weights, pose2rot=True)[source]#
Performs Linear Blend Skinning with the given shape and pose parameters.
- Parameters:
betas (torch.tensor BxNB) – The tensor of shape parameters
pose (torch.tensor Bx(J + 1) * 3) – The pose parameters in axis-angle format
BxVx3 (v_template torch.tensor) – The template mesh that will be deformed
shapedirs (torch.tensor 1xNB) – The tensor of PCA shape displacements
posedirs (torch.tensor Px(V * 3)) – The pose PCA coefficients
J_regressor (torch.tensor JxV) – The regressor array that is used to calculate the joints from the position of the vertices
parents (torch.tensor J) – The array that describes the kinematic tree for the model
lbs_weights (torch.tensor N x V x (J + 1)) – The linear blend skinning weights that represent how much the rotation matrix of each part affects each vertex
pose2rot (bool, optional) – Flag on whether to convert the input pose tensor to rotation matrices. The default value is True. If False, then the pose tensor should already contain rotation matrices and have a size of Bx(J + 1)x9
dtype (torch.dtype, optional) –
- Returns:
verts (torch.tensor BxVx3) – The vertices of the mesh after applying the shape and pose displacements.
joints (torch.tensor BxJx3) – The joints of the model
- medusa.recon.flame.lbs.blend_shapes(betas, shape_disps)[source]#
Calculates the per vertex displacement due to the blend shapes.
- Parameters:
betas (torch.tensor Bx(num_betas)) – Blend shape coefficients
shape_disps (torch.tensor Vx3x(num_betas)) – Blend shapes
- Returns:
The per-vertex displacement due to shape deformation
- Return type:
torch.tensor BxVx3
- medusa.recon.flame.lbs.batch_rodrigues(rot_vecs, epsilon=1e-08)[source]#
Calculates the rotation matrices for a batch of rotation vectors :param rot_vecs: array of N axis-angle vectors :type rot_vecs: torch.tensor Nx3
- Returns:
R – The rotation matrices for the given axis-angle parameters
- Return type:
torch.tensor Nx3x3
- medusa.recon.flame.lbs.transform_mat(R, t)[source]#
Creates a batch of transformation matrices :param - R: Bx3x3 array of a batch of rotation matrices :param - t: Bx3x1 array of a batch of translation vectors
- Returns:
Bx4x4 Transformation matrix
- Return type:
T
- medusa.recon.flame.lbs.batch_rigid_transform(rot_mats, joints, parents)[source]#
Applies a batch of rigid transformations to the joints.
- Parameters:
rot_mats (torch.tensor BxNx3x3) – Tensor of rotation matrices
joints (torch.tensor BxNx3) – Locations of joints
parents (torch.tensor BxN) – The kinematic tree of each object
dtype (torch.dtype, optional:) – The data type of the created tensors, the default is torch.float32
- Returns:
posed_joints (torch.tensor BxNx3) – The locations of the joints after applying the pose rotations
rel_transforms (torch.tensor BxNx4x4) – The relative (with respect to the root joint) rigid transformations for all the joints