Jeff-sjtu / HybrIK

Official code of "HybrIK: A Hybrid Analytical-Neural Inverse Kinematics Solution for 3D Human Pose and Shape Estimation", CVPR 2021
MIT License
1.21k stars 147 forks source link

How to visualize smpl joint points? #140

Closed He-Chao closed 1 year ago

He-Chao commented 1 year ago

I want to visualize smpl joints like this image But when I use pose_output.pred_xyz_jts_24_struct, it's not right image When I use pose_output.pred_xyz_jts_24_struct as SMPL input pose, I get result T-pose image Input image is 000000000431 Can someone help me?

asicdesign commented 1 year ago

HI He-Chao, Not sure if this addresses your question: [https://github.com/Jeff-sjtu/HybrIK/issues/92#issuecomment-1285203410]

srn-source commented 1 year ago

Can you do that is it possible to suggest me how to do?

merlinyx commented 1 year ago

@srn-source if you want to get the joint positions you can run the smpl model forward() with parameters from the pose_output of hybrik's output:

from pytorch3d import transforms
import smplx

aa = transforms.matrix_to_axis_angle(pose_output.pred_theta_mats.reshape(-1, 3, 3))
global_orient = aa[:3].unsqueeze(0)
body_pose = aa[3:].unsqueeze(0)
model_n = smplx.create("<path to smpl models>", model_type="smpl", gender="neutral")
output_n = model_n(betas=pose_output.pred_shape.detach().cpu(), global_orient=global_orient.detach().cpu(), body_pose=body_pose.detach().cpu(), transl=pose_output.transl.detach().cpu())

joints = output_n.joints[0, :24, :]
joints = joints.detach().cpu().numpy()

joints are the 3d positions of the 24 joints and then you can use whatever visualization tool you like to draw them. I don't know why though the reconstructed smpl body doesn't align with the pose_output.pred_vertices positions (with pose_output.transl applied), but since it's a fixed offset it's probably no big deal just in terms of getting joint positions.