text-to-motion icon indicating copy to clipboard operation
text-to-motion copied to clipboard

How can the output data be converted to bvh format?

Open makeme-zgz opened this issue 2 years ago • 13 comments

I'm trying to convert the rotations and joint position into bvh format so that I can do better visualization. I can see that there is an IK method in the motion_process.py file which might help me to get the local rotation information. But it turns out that it's not correct. I fed in the joint positions returned by recover_from_ric method.

Would be appreciate if any help or hint is provided.

makeme-zgz avatar Jun 29 '22 05:06 makeme-zgz

Hi, I tried many times to visualize the results in bvh format but failed. I feel it is more complicated than I suppose. So I will be glad if you can figure it out. As far as I know, bvh is in "euler angle" rotation representation.

Use the following code:

from common.skeleton import Skeleton import numpy as np import os from common.quaternion import * from utils.paramUtil import *

example_data = np.load(os.path.join(data_dir, example_id + '.npy')) example_data = example_data.reshape(len(example_data), -1, 3) example_data = torch.from_numpy(example_data) skel = Skeleton(n_raw_offsets, kinematic_chain, 'cpu') offsets = skel.get_offsets_joints(example_data[0])

face_joint_indx = [2, 1, 17, 16] quat_params = skel.inverse_kinematics_np(example_data, face_joint_indx, smooth_forward=False)

Then the quat_params are the local rotations in quaternion representation. Note the root rotations are respect to Z+ direction. Hope it helps.

EricGuo5513 avatar Jun 29 '22 18:06 EricGuo5513

Thank you very much for the reply! Quick question on the example data, is it the global or local position of the joints? What would the first entry be like?

makeme-zgz avatar Jun 30 '22 05:06 makeme-zgz

Hi, the example data use global positions of joints. It is in the same format as what you obtained through recover_from_ric method. You may also need to add these two lines:

n_raw_offsets = torch.from_numpy(t2m_raw_offsets) kinematic_chain = t2m_kinematic_chain

So this quat_params give you the local rotations of each bone with respect to the pre-defined offsets.

EricGuo5513 avatar Jun 30 '22 17:06 EricGuo5513

Hello! has this problem been solved? Can you share the method with me?

zhuangzhuang000 avatar Jul 09 '22 03:07 zhuangzhuang000

Converting the SMPL pose to BVH was easy, and I got that done yesterday.

foamliu avatar Oct 29 '22 00:10 foamliu

Converting the SMPL pose to BVH was easy, and I got that done yesterday.

Hello! Could you share the method with me? Thank you very much!

zhuangzhuang000 avatar Oct 29 '22 02:10 zhuangzhuang000

Converting the SMPL pose to BVH was easy, and I got that done yesterday.

Hi, if possible, could you please send the code or github repos? I am very interested. Thanks.

EricGuo5513 avatar Oct 31 '22 15:10 EricGuo5513