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_rotation_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.2) 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.2.tar.gz (203.9 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.2-py3-none-any.whl (213.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pybvh-0.8.2.tar.gz
  • Upload date:
  • Size: 203.9 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.2.tar.gz
Algorithm Hash digest
SHA256 71474daa6a223cd237a65f1f83cac9996b51219fe476fa1031cb568ab49a2b63
MD5 fb173f379913fc6175a71f14747293bc
BLAKE2b-256 03de638ddcb69e71d70163dab23500410d3955424aded4501f9551fbc27dea5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybvh-0.8.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: pybvh-0.8.2-py3-none-any.whl
  • Upload date:
  • Size: 213.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 aa80536182595b4a81dd671dcd340c1270a1ad879baef90768825fc85cef8b0d
MD5 17032548315644f412c131114f62ede1
BLAKE2b-256 9a05829ca3d65c518be4c13dd319dbcfc0a3e6628916538dc5952d694783aeeb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybvh-0.8.2-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

This release

0.8.2 This release

2 files

0.8.1

2 files

0.8.0

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