I/O¶
io
¶
BVH file I/O — reading and writing .bvh motion capture files.
Public functions:
- :func:
read_bvh_file— parse a.bvhfile into a :class:~pybvh.bvh.Bvh - :func:
write_bvh_file— write a :class:~pybvh.bvh.Bvhto a.bvhfile
read_bvh_file(filepath: str | Path, world_up: str = 'auto', warn_on_world_up_disagreement: bool = True, lr_mapping: dict[str, str] | None = None) -> Bvh
¶
Parse a BVH motion capture file and return a Bvh object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str or Path
|
Path to the BVH file. |
required |
world_up
|
str
|
World vertical axis. |
'auto'
|
warn_on_world_up_disagreement
|
bool
|
If True (default) and |
True
|
lr_mapping
|
dict or None
|
Explicit left/right joint pair mapping
( |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bvh |
Bvh
|
A Bvh object containing the skeleton hierarchy, root positions, joint angles, and frame time. |
Notes
BVH files store joint angles in degrees; pybvh holds them in radians
on :attr:Bvh.joint_angles. This function converts on read;
:func:write_bvh_file converts back on write. Round-trip is lossless
within float precision.
write_bvh_file(bvh: Bvh, filepath: str | Path, verbose: bool = False) -> None
¶
Write a Bvh object to a .bvh file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bvh
|
Bvh
|
The motion data to write. |
required |
filepath
|
str or Path
|
Destination file path. Must have a |
required |
verbose
|
bool
|
If True, print a one-line confirmation to stdout on success.
Default |
False
|
Raises:
| Type | Description |
|---|---|
Exception
|
If the file extension is not |
Notes
pybvh stores joint angles in radians, but the BVH format requires degrees; this function converts on write.