smplx icon indicating copy to clipboard operation
smplx copied to clipboard

smplx to bvh

Open Neptune-Trojans opened this issue 2 years ago • 6 comments

Hi,

Is there a way to export the skeleton motion to bvh format ? Do you have some example for that ?

Thanks.

Neptune-Trojans avatar Jan 13 '22 10:01 Neptune-Trojans

If you can load the data into fairmotion you can save to .bvh with their bvh.save. AMASS files can be loaded using fairmotion.data.amass. I'm not an author of this repo or fairmotion, this is the just the easiest way I've found to get .bvh files at the moment.

gngdb avatar Jan 31 '22 17:01 gngdb

Hi,

Is there a way to export the skeleton motion to bvh format ? Do you have some example for that ?

Thanks.

I have the same question, and I want to know that you have already solve it? Could you please share the method? Thanks very much!!!

sycamore27 avatar Mar 15 '22 09:03 sycamore27

Hi, Is there a way to export the skeleton motion to bvh format ? Do you have some example for that ? Thanks.

I have the same question, and I want to know that you have already solve it? Could you please share the method? Thanks very much!!!

Hi, I also meet the same question, and I also want to know that you have already solve it? Thank you very much!!

Cicistrawberry avatar Dec 31 '22 10:12 Cicistrawberry

We don't have an exporter for .bvh but it would not be hard to implement. The bvh format is simple (https://research.cs.wisc.edu/graphics/Courses/cs-838-1999/Jeff/BVH.html). We've never done this because bvh throws away the information about body shape so it is a lossy transformation.

MichaelJBlack avatar Dec 31 '22 16:12 MichaelJBlack

Hi @Cicistrawberry ,

What I finally did is similar to what @gngdb suggested. I exported from the SMPL format the skeleton connectivity plus all the rotation, translation data and then loaded it to fairmotion library and then saved it as bvh file. I dont have access to this code so I am sorry that I cannot share it.

Neptune-Trojans avatar Jan 01 '23 07:01 Neptune-Trojans

We don't have an exporter for .bvh but it would not be hard to implement. The bvh format is simple (https://research.cs.wisc.edu/graphics/Courses/cs-838-1999/Jeff/BVH.html). We've never done this because bvh throws away the information about body shape so it is a lossy transformation.

This gets the job done:

from fairmotion.data import amass, bvh
import os

prefix = f'./<data-dir-path-here>' # eg: './AMASS/TotalCapture/s1'

# list all the files in the directory
files = [f for f in os.listdir(prefix)]

bm_path = './<body-model-path-here>'  # eg: body_models/smplh/neutral/model.npz' 
motion = [bvh.save(amass.load(os.path.join(prefix, f), bm_path=bm_path, model_type="smplh"),
 f"{os.path.join(prefix, f.split('.')[0]) + '.bvh'}") for f in files]

Note: fairmotion.data.amass will throw an error (installed with pypi) TypeError: __init__() missing 1 required positional argument: 'model_type'. Simply add it to load_body_model() in the file.

Similar issue with human_body_prior package TypeError: lbs() got an unexpected keyword argument 'dtype'. Simply remove the arg from the lbs() in the forward function of body_model.BodyModel.

It works fine after that. Could train amass on deep-motion-editing thereafter which requires .bvh files Cheers.

AntiLibrary5 avatar May 25 '23 15:05 AntiLibrary5