yohanshin / WHAM

MIT License
674 stars 73 forks source link

Getting rotation information from results (demo.py) #96

Open wthIC opened 4 months ago

wthIC commented 4 months ago
    pred_body_pose = matrix_to_axis_angle(pred['poses_body']).cpu().numpy().reshape(-1, 69)
    pred_root = matrix_to_axis_angle(pred['poses_root_cam']).cpu().numpy().reshape(-1, 3)
    pred_root_world = matrix_to_axis_angle(pred['poses_root_world']).cpu().numpy().reshape(-1, 3)
    pred_pose = np.concatenate((pred_root, pred_body_pose), axis=-1)
    pred_pose_world = np.concatenate((pred_root_world, pred_body_pose), axis=-1)
    pred_trans = (pred['trans_cam'] - network.output.offset).cpu().numpy()

    results[_id]['pose'] = pred_pose
    results[_id]['trans'] = pred_trans
    results[_id]['pose_world'] = pred_pose_world
    results[_id]['trans_world'] = pred['trans_world'].cpu().squeeze(0).numpy()
    results[_id]['betas'] = pred['betas'].cpu().squeeze(0).numpy()
    results[_id]['verts'] = (pred['verts_cam'] + pred['trans_cam'].unsqueeze(1)).cpu().numpy()
    results[_id]['frame_ids'] = frame_id

I took this snippet from demo.py where the results are saved. I have been filtering these results into a CSV file to save only the positional information and joint rotations. For now, I have been deriving the joint coordinates from the 'verts' and using values in 'pose_world' as the joint rotations as angles in radians in the x,y, and z coordinate systems. Are my assumptions wrong regarding these?

yohanshin commented 4 months ago

verts are the 3D position (in the camera coordinate system) of 6,890 SMPL vertices. pose_world is indeed the joint rotations as axis angle representation, indicating the relative rotation of a body segment with respect to its parent body segment (e.g., left knee rotation is relative rotational transformation between left shank and left thigh).

wthIC commented 4 months ago

Thank you for confirming my assumptions. I wanted to also know what is the domain for these angles. I believe the unit for joint rotations is radians. From what I have read, the domain seems like it should be between -180 and 180 degrees when converted, but I have seen angles bigger than 180.