nv-tlabs / ASE

Other
788 stars 125 forks source link

How can I get the skeleton for re-targeting from a fbx file? #40

Closed Robokan closed 1 year ago

Robokan commented 1 year ago

I just want to thank you for publishing the source code to this amazing paper!

I have a fbx file with 2 frames of animation both have the the skeleton in tpose. I am trying to get a tpose for retargeting from the fbx file so I tried:

fbx_file = "/home/bizon/Documents/to_ase/MM_T_Pose.FBX"

motion = SkeletonMotion.from_fbx( fbx_file_path=fbx_file, root_joint="pelvis", fps=60 )

skeleton_fbx = motion.skeleton_tree zero_pose_fbx = SkeletonState.zero_pose(skeleton_fbx)

plot_skeleton_state(zero_pose_fbx)

The result is a mangled skeleton.

if try: plot_skeleton_motion_interactive(motion)

I get a perfect skeleton. So I know the fbx file is good. What is the right way to get the Skeleton in tpose?

other observations: If I print the sample Skeleton loaded from cmu_tpose.npy and the Skeleton loaded from 07_01_cmu.fbx. They are identical (other than local_translation). What's different is the SkeletonState on each. So I am assuming I am missing some kind of transform that needs to be done. I wonder, how was the cmu_tpose.npy originally created from the fbx file? That answer is probably the solution.

Robokan commented 1 year ago

I figured out the solution. Assuming the tpose is the first frame of the animation in a FBX file (which it is in the CMU animations) then this will get the tpose from the first frame and save it for use in retargeting. To use this on some other motion capture file just get some animation with a tpose in it and then grab the frame and save it.

fbx_file = "data/07_01_cmu.fbx"

motion = SkeletonMotion.from_fbx( fbx_file_path=fbx_file, root_joint="Hips", fps=60 )

tpose = SkeletonState.zero_pose(motion.skeleton_tree)

first_frame = motion.tensor[0, :] tpose.tensor = first_frame tpose.to_file("data/custom/cmu_tpose_test.npy")

plot_skeleton_state(tpose)

xbpeng commented 1 year ago

glad you figured it out