BVH reader/writer and kinematics utilities
Project description
UPDATE :
- 2025-03-26: Added a bone size scaling method.
- 2025-02-28: Added the possibility to use another skeleton than the one in the bvh file itself. Separated the tutorial into multiple files, for readability, and updated the content.
- 2025-01-25: Change the parameter "local" in the functions to get spatial coordinates and to plot the bvh. The new parameter is "centered", with three modes:
- "skeleton": equivalent to previous local = True, root pos always 0, 0, 0:
- "world": equivalent to previous local = False, root at coordinates as in saved in bvh frames
- "first": the first frame root position is 0, 0, 0. From there, the skeleton moves in the space normally.
pybvh
Python library to work with bvh files
The main point of this library is a Bvh class, which contains all the necesseray information found in a bvh file. Through the use of this object, it is easy to read and write a bvh file, but also to convert it to a Pandas Dataframe, and conversely to transform a Dataframe into a bvh object.
See the jupyter file 'tutorial' for example of use.
Installation
- Stable release from PyPI:
pip install pybvh - With pandas helpers (optional):
pip install "pybvh[pandas]"
Notes about data and notebooks
- Example BVH files and tutorial notebooks are not bundled in the PyPI package to keep the wheel slim.
- You can find the sample BVH data and notebooks in the GitHub repository under
bvh_data/andtutorials/.
Curent functionality
-
Bvh class
- parameters :
- bvhobject.nodes: a list of all the nodes in the Hierarchy. The nodes are BvhRoot, BvhJoint or BvhNode objects for respectively the root, the joints and the end sites.
- bvhobject.frames: the rotational data as a 2D numpy array.
- bvhobject.frame_frequency: the frames frequency as can be found in a bvh file.
- bvhobject.frame_template: the organized name of each column of the bvhobject.frames.
- bvhobject.frame_count: the number of frames (=the number of lines of the bvhobject.frames parameter).
- bvhobject.root: the root of the Hierarchy, aka bvhobject.nodes[0].
- methods :
- to_bvh_file(filepath, verbose=True): save a bvh object to a bvh file at the location filepath (str or Path object).
- get_spatial_coord(frame_num=-1, centered="world"): get the spatial coordinates of every joints for all frames or only one.
- get_df_constructor(mode = 'euler', centered="world"): get a list of dictionnary that can be transmitted to a pd.Dataframe() constructor to directly obtain a Dataframe. Can construct a DataFrame with euler angles or spatial coordinates.
- hierarchy_info_as_dict(): get a dictionnary describing the organisation of the Hierarchy in the bvh object.
- change_skeleton(new_skeleton, inplace=False): copy the nodes offset from the 'new_skeleton' bvh object.
- scale_skeleton(scale, inplace=False): scale the nodes offset.
- parameters :
-
read_bvh_file(filepath) : read a .bvh file at the filepath location (str or Path object), and create a Bvh object
-
df_to_bvh(hier, df) : df is a pandas DataFrame, containing joints rotational data. hier is either a dictionnary describing the hierarchy, or a list of nodes. Will create a bvh object based on those two arguments.
-
plot.plot_frame(bvh_object, frame) : plot a matplotlib projection3d that shows the frame passed as a parameter.
TODO:
- making direct changes to rot_channels and pos_channels impossible/regulated. Needs to go through a class method, so that we can also change the frames columns order (and value!) at the same time.
- class method to transform euler angle directly (different Euler angle order, transformation to rotation matrix etc.)
- change docstrings to Numpy/Scipy standard
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pybvh-0.2.0.tar.gz.
File metadata
- Download URL: pybvh-0.2.0.tar.gz
- Upload date:
- Size: 31.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc1459ef9aab63f87ec26daeccfd0a3f9dd06c5ea7cdb0a39dfd654e07e5464a
|
|
| MD5 |
355529993025c6f22da0bb7371189cc9
|
|
| BLAKE2b-256 |
fbc1e2d777b0fc29a02077102598433639dfba8aaa74fa8f86fc39a4fa24db58
|
Provenance
The following attestation bundles were made for pybvh-0.2.0.tar.gz:
Publisher:
publish.yml on VictorS-67/pybvh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pybvh-0.2.0.tar.gz -
Subject digest:
dc1459ef9aab63f87ec26daeccfd0a3f9dd06c5ea7cdb0a39dfd654e07e5464a - Sigstore transparency entry: 956853308
- Sigstore integration time:
-
Permalink:
VictorS-67/pybvh@2a6ce7399a0164f580cb7d4e2969315687d74fca -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/VictorS-67
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2a6ce7399a0164f580cb7d4e2969315687d74fca -
Trigger Event:
release
-
Statement type:
File details
Details for the file pybvh-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pybvh-0.2.0-py3-none-any.whl
- Upload date:
- Size: 32.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c19ec2ca5894c4f307fba83f0269cbe87c6fd40ec611b90d74bc9a1ff8531ef
|
|
| MD5 |
bb16ddce293c6749362cf245c1d3eda1
|
|
| BLAKE2b-256 |
ff2e8cc0191213b7f98eae3674d53eaa6a381f022b199446adea71283d45c1a3
|
Provenance
The following attestation bundles were made for pybvh-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on VictorS-67/pybvh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pybvh-0.2.0-py3-none-any.whl -
Subject digest:
7c19ec2ca5894c4f307fba83f0269cbe87c6fd40ec611b90d74bc9a1ff8531ef - Sigstore transparency entry: 956853339
- Sigstore integration time:
-
Permalink:
VictorS-67/pybvh@2a6ce7399a0164f580cb7d4e2969315687d74fca -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/VictorS-67
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2a6ce7399a0164f580cb7d4e2969315687d74fca -
Trigger Event:
release
-
Statement type: