Code Monkey home page Code Monkey logo

bvh-toolbox's Introduction

This repository provides Python3 scripts for manipulating and converting BVH motion capture files.

Latest version on PyPI Test Python package

Installation

  • To install from PyPi:
    pip install bvhtoolbox
  • To install from github using development mode:
    pip install -e git+https://github.com/OlafHaag/bvh-toolbox.git@master#egg=bvhtoolbox
  • To install latest development version using regular mode (building the package):
    pip install https://github.com/OlafHaag/bvh-toolbox/archive/master.zip
  • The installation creates some console scripts you can use.

Console scripts

Manipulate BVH files

Rename joints in bvh files

  • Command: bvhrenamejoints

Remove frames from BVH files

  • Command: bvhremoveframes

Offset joint angles in BVH files

  • Command: bvhoffsetjointangles
  • Can be used to additively offset joint angles in the BVH by supplying a csv table containing the mapping of joint names to euler angles.
    • The angles must be in the same order as the joint's channels in the BVH hierarchy.

Convert from or to BVH files

BVH to Cal3D XSF & XAF

  • Command: bvh2xsf
  • Command: bvh2xaf
  • Converts BVH files to the Cal3D XML skeleton (XSF) and animation (XAF) file formats.
  • The XAF files rely on the respective skeleton file.
  • XAF files have been tested to work with skeletons that were exported from 3DS Max and Blender.
  • I use the resulting xaf files in Worldviz' Vizard, so it's only been tested in this context.

BVH to Panda3D Egg animation file

  • Command: bvh2egg
  • Converts BVH files to the Panda3D animation file egg format.

BVH to CSV tables

  • Command: bvh2csv
  • Converts BVH to comma separated values tables.
  • Ouputs one file for hierarchy, one for joint rotations, and one for joint world positions.
  • Use --hierarchy to export the respective CSV file.
  • Using only the --rotation or the --position flag you can output only one of the transform tables.
  • The --out parameter only takes a directory path as an argument.
  • With the --ends flag the End Sites are included in the *_pos.csv file.

CSV tables to BVH

  • Command: csv2bvh
  • Takes 3 CSV files (hierarchy, rotation, position) previously exported using bvh2csv or created otherwise and builds a bvh file from them.

All converters have a --scale parameter taking a float as an argument. You can use it to convert between units for the position and offset values.

How to run the console batch scripts

  • Open terminal.
  • If you've installed the bvhtoolbox into a conda/virtual environment, you have to activate it first.
  • type <script_name> -h (substitute <script_name> by one of the commands above) to get more information on the usage.

Notes

This package includes 20tabs' bvh module due to a lack of updates for this module on pypi.org.

bvh-toolbox's People

Contributors

olafhaag avatar yanchxx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

bvh-toolbox's Issues

bvh2csv throws error NotADirectoryError

Using up to date Archlinux
bvh2csv /home/olivier/Entry-1F.bvh --rotation --out /home/olivier Traceback (most recent call last): File "/usr/bin/bvh2csv", line 11, in <module> load_entry_point('bvhtoolbox==0.1.0', 'console_scripts', 'bvh2csv')() File "/usr/lib/python3.8/site-packages/bvhtoolbox/convert/bvh2csv_batch.py", line 107, in main os.chdir(src_folder_path) NotADirectoryError: [Errno 20] Not a directory: '/home/olivier/Entry-1F.bvh'

CSV converter

Export rotations, and world position of joints to CSV files respectively.

csv2bvh crash in reading hierarchy

ValueError: Changing the dtype to a subarray type is only supported if the total itemsize is unchanged

line 59, in get_hierarchy_data
offsets = rec_array[['offsetx', 'offsety', 'offsetz']].copy().view((float, 3))

Revisit rotation conversation to csv. It's way too slow!

The conversion is walking the BVH tree for each frame. But the file already has all the rotation values and it just needs to be filtered.

Maybe the values still need conversion because of rotation order or something else. Should check.
There's definitely much room for performance impovement.

Error in bvh_tree.write_file()

write() raise Error while it write _get_hierarchy_string(). The error is
IndexError: key CHANNELS not found
The error occur when it try to access the child with End Site, which should have no CHANNELS property.

ModuleNotFoundError: No module named 'numpy'

How to actually use the bvh2csv (and csv2bvh) script? Trying to launch it, but getting the error of no module named 'numpy' Numpy installed, actually.

Should I install the bvh-toolbox first somehow? Also, getting error running setup.py - error in bvhtoolbox setup command: ('Duplicate entry point', 'console_scripts', 'bvh2egg')

No animation

I got some Position and rotation data from Azure Kinect. I have converted Azure Kinect Quaternion data to Euler angles and I have set up my hierarchy according to Microsoft documentation. However, after converting my position and orientation data to bvh, no motion is shown when I played the bvh file.

FIles are attached.
Windows OS
Motion type: T-pose
ex_hei.zip

csv2bvh does not work

Which tool (if any in particular)
I was using the csv2bvh tool. I am on MacOS. I am using Python 3.8.

Describe the bug
The bug causes this error:

  File "/usr/local/bin/csv2bvh", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bvhtoolbox/convert/csv2bvh.py", line 473, in main
    success = csv2bvh_file(hierarchy_src, position_src, rotation_src, dst_file_path)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bvhtoolbox/convert/csv2bvh.py", line 447, in csv2bvh_file
    data = csv2bvh_string(hierarchy_file, position_file, rotation_file, scale)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bvhtoolbox/convert/csv2bvh.py", line 360, in csv2bvh_string
    raise Exception("ERROR: No rotation data found for: {}".format(", ".join(missing_joint_data)))
Exception: ERROR: No rotation data found for: 

To Reproduce
Steps to reproduce the behavior:

  1. Run command
    csv2bvh hierarchy.csv position.csv rotation.csv

Expected behavior
The files convert into a BHV file

Additional context
Here are are the CSV files I am using:
https://drive.google.com/drive/folders/1lTKWIRG16m5JfHO52vjNKG1WYOvyFlFr?usp=sharing

fix entry points/init imports

RuntimeWarning: 'bvhtoolbox.convert.bvh2csv' found in sys.modules after import of package 'bvhtoolbox.convert', but prior to execution of 'bvhtoolbox.convert.bvh2csv'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))

bvhrenamejoints example?

Any possibility of adding an example or more documentation for renaming joints?

I see:

for row in csv_reader:
mapping[row[0]] = row[1]

But no matter what I'm getting: NameError: name 'mapping' is not defined.

Thank you!

Writing to/from csv truncates joint names

data = np.array(data, dtype=[('joint', np.unicode_, 20),

('parent', np.unicode_, 20),

limits the length of the joint names to 20, but in tests, you have joint names which are much longer, creating artifacts in the csvs such as:

mixamorig:LeftHandMi,mixamorig:LeftHandMi, 3.60930, -0.16690, 0.07780
mixamorig:LeftHandMi,mixamorig:LeftHandMi, 3.40040, -0.62740, 0.11480
mixamorig:LeftHandMi,mixamorig:LeftHandMi, 3.62050, -0.64930, 0.11990

Maybe adding an invertibility test (bvh -> csv -> bvh) would be of value? This could be part of #11

Numpy version Issues

Which tool (if any in particular)
Which tool did you try to use that caused the issue?

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Run command '...'
  2. With input files '....'
  3. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

I installed the new Numpy Lib while processing with bvh.

numpy version = 1.26.4

I could see that the numpy version of bvhtoolbox was low.

If anyone is experiencing this problem, this error will not occur if you use numpy version 1.20 or lower.

AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.