Skip to main content

pybvh

PyPI version Python Docs License: MIT

A lightweight Python library for reading, writing, and manipulating BVH motion capture files. Built for researchers and developers working with skeletal animation and motion data.

A skeleton animates while its hand traces a blue trajectory — pybvh renders motion and extracts analyzable trajectories from it

Documentation · Quick Start · Feature Gallery — every feature, one picture each · Find a function · Tutorials

Features

  • Read & write BVH files with full hierarchy and motion data preservation — I/O
  • Rotation conversions between Euler angles, rotation matrices, quaternions, 6D (Zhou et al.), and axis-angle — all vectorized with NumPy — guide
  • Forward kinematics to compute 3D joint positions from angles — core concepts
  • Skeleton operations: retargeting, scaling, joint extraction, Euler order changes — guide
  • Frame operations: slicing, concatenation, resampling to different frame rates — guide
  • Spatial transforms: mirroring, vertical rotation, speed perturbation, joint noise, root translation, frame dropout — all with seeded randomization — guide
  • Motion analysis: joint velocities/accelerations, root trajectory, foot contact detection, gait parameters, and a one-stop to_feature_array() export — guide
  • Motion descriptors: trajectory geometry (curvature, torsion, path length, bounding volumes, centre of mass), dynamics (jerk, smoothness/SPARC, kinetic energy, gait), and SE(3) rigid-transform math (twists, screw interpolation, geodesic distance) — all pure NumPy — guide · gallery
  • Signal utilities (pybvh.signal): finite differences, temporal statistics, smoothing, FFT/dominant frequency, polyline simplification — API
  • Batch loading of entire directories with optional parallel I/O — guide
  • Pandas readyto_df_dict() output drops straight into pd.DataFrameguide
  • 3D visualization with multiple backends (matplotlib, OpenCV, k3d, vedo) — API

Philosophy

pybvh is framework-agnostic and outputs pure NumPy arrays. It understands motion capture data but does not assume what you'll do with it — the same library serves ML researchers, biomechanics scientists, and game developers. For ML-specific features (tensor packing, PyTorch Datasets, augmentation pipelines), see the companion library pybvh-ml (documentation).

Installation

pip install pybvh

Quick Start

import pybvh

# Load a BVH file (pybvh.Bvh.from_file("walk.bvh") is the classmethod spelling)
bvh = pybvh.read_bvh_file("walk.bvh")
print(bvh)  # "24 joints, 75 frames at 30.0 fps (frame_time=0.033333s, from walk.bvh)"

# Access motion data as NumPy arrays
bvh.root_pos          # (F, 3) root translation per frame
bvh.joint_angles      # (F, J, 3) Euler angles in radians
bvh.joint_names       # ['Hips', 'Spine', ...] (excludes end sites)

# Get 3D joint positions via forward kinematics
coords = bvh.node_positions()  # (F, N, 3)

# Convert to other rotation representations
root_pos, quats = bvh.to_quat()          # (F, 3), (F, J, 4)
root_pos, rot6d = bvh.to_6d()            # (F, 3), (F, J, 6)

# Write back to file
bvh.write("output.bvh")

Motion Analysis

vel = bvh.joint_velocities()    # (F, J, 3) in units/second
contacts = bvh.foot_contacts()  # (F, num_feet) binary labels, feet auto-detected

# One-stop export — flat feature array for ML pipelines
features = bvh.to_feature_array(
    representation="6d",
    include_velocities=True,
    include_foot_contacts=True,
)  # (F, D)

Beyond the basics sits a full descriptor layer — curvature, smoothness (SPARC), kinetic energy, gait parameters, SE(3) twists — each drawn with its exact call in the Feature Gallery and explained in the Motion Descriptors guide.

Visualization

bvh.plot_rest_pose()                             # T-pose
bvh.plot_frame(frame=0, camera="front")          # also "side", "top", (azim, elev)
bvh.plot_trajectory()                            # 2D top-down root path
bvh.render("walk.mp4")                           # video/GIF/HTML export
bvh.render("walk.mp4", follow=True)              # camera tracks character as it turns
bvh.play()                                       # interactive playback (auto-detects backend)
pip install pybvh[opencv]       # Fast video rendering
pip install pybvh[interactive]  # k3d for Jupyter notebooks
pip install pybvh[viewer]       # vedo for desktop interactive viewer
pip install pybvh[all-viz]      # All of the above

Multi-skeleton comparison, camera control, and backend details: Visualization API.

More

Topic In one line Docs
Batch loading Load a directory, harmonize heterogeneous skeletons, export one padded array Feature Export
Spatial transforms mirror, rotate_vertical, add_noise, perturb_speed, drop_frames — seeded randomization Data Augmentation
Skeleton & frame ops retarget, scale, extract_joints, slicing, concatenation, resample Skeleton Operations
Rotation utilities Batch-vectorized conversions between all five representations, SLERP, SE(3) Rotations & SE(3)
World up & orientation Up-axis detection, forward_at/left_at, reorientation World Up
Pandas integration to_df_dict() / df_to_bvh() round trip Skeleton Operations

Tutorials

Eight Jupyter notebooks with detailed walkthroughs, from reading your first file to motion descriptors — see the tutorials page. Each tutorial is committed as a Jupytext-paired .ipynb + .py so the source is reviewable as plain Python.

Stability and versioning

pybvh is in 0.x — expect breaking changes between minor versions.

We treat 0.x as design space: when a past choice turns out to be wrong, we fix it at the root rather than carry scar tissue forward. No deprecation cycles, no compatibility shims; each release ships a single clean migration path, documented in the CHANGELOG. If you depend on pybvh from production code, pin to an exact version (pybvh==0.8.0) and read the upgrade notes before bumping.

This will change at 1.0: from then on, pybvh will commit to strict semver — no breaking changes within a major version, deprecation warnings (at least one minor release) before any future removal. Until 1.0, "make the library better" wins over "preserve the old behavior."

Requirements

  • Python >= 3.9
  • NumPy >= 1.21
  • Matplotlib >= 3.7

Pandas is optional (pip install "pybvh[pandas]") - only used in the tutorials, not part of pybvh library.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybvh-0.8.0.tar.gz (178.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybvh-0.8.0-py3-none-any.whl (187.5 kB view details)

Uploaded Python 3

File details

Details for the file pybvh-0.8.0.tar.gz.

File metadata

  • Download URL: pybvh-0.8.0.tar.gz
  • Upload date:
  • Size: 178.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pybvh-0.8.0.tar.gz
Algorithm Hash digest
SHA256 213671efc24c8c04b2c8874cc46796946cd31413714f4da826bc58134a2651f4
MD5 918282f29766d577a436f911d3b044fd
BLAKE2b-256 5537884e836bcecf6cb422ba881f76a9d4a4ea5e9897ff53f799c91f7dc487c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybvh-0.8.0.tar.gz:

Publisher: publish.yml on VictorS-67/pybvh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pybvh-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: pybvh-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 187.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pybvh-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 576be6d0c8e7601336e767ad1d5f3ae538851fa225598d08a074e47e528e80e4
MD5 9a6a42fa2f0515fd754d4986643af5ea
BLAKE2b-256 2fe616c54faf25b891670cd075fd4fdab5cc140fc9b2a3f197bd278eabf30390

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybvh-0.8.0-py3-none-any.whl:

Publisher: publish.yml on VictorS-67/pybvh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.8.2

2 files

0.8.1

2 files

This release

0.8.0 This release

2 files

0.7.0

2 files

0.6.0

2 files

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page