Wasserwecken / bvhio

Read, write, edit and create .bvh files with hierarchical 3D transforms
MIT License
47 stars 11 forks source link

`bvhio.convertBvhToHierarchy()` method is not properly handling the BVH data structure returned by `bvhio.readAsBvh()` #19

Closed sascharo closed 3 months ago

sascharo commented 3 months ago

I read BVH files from the Carnegie-Mellon Graphics Lab Motion Capture Database and from the Bandai-Namco-Research-Motiondataset, but when converting it to a hierarchical structure with bvhio.convertBvhToHierarchy I get the following error:

self.hierarchy = bvhio.convertBvhToHierarchy(bvh_data)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".\Lib\site-packages\bvhio\lib\Parser.py", line 71, in convertBvhToHierarchy
  restPose = Transform(name=f'RestPose.{bvh.Name}', position=bvh.Offset, rotation=bvh.getRotation())
                                          ^^^^^^^^
AttributeError: 'BvhContainer' object has no attribute 'Name'

What is the reason for that, and any idea how I can prevent it?

Wasserwecken commented 3 months ago

It looks like you passed the wrong object to the method. The method expects a 'BvhJoint' but you passed the 'BvhContainer'. If you look to this example here ,you can use the root joint from the container.

The fix for your code might be probably: self.hierarchy = bvhio.convertBvhToHierarchy(bvh_data.Root)

sascharo commented 3 months ago

It looks like you passed the wrong object to the method. The method expects a 'BvhJoint' but you passed the 'BvhContainer'. If you look to this example here ,you can use the root joint from the container.

The fix for your code might be probably: self.hierarchy = bvhio.convertBvhToHierarchy(bvh_data.Root)

You're correct. Thanks for the help!