This is a small library for reading and writing C3D binary files. C3D files are a standard format for recording 3-dimensional time sequence data, especially data recorded by a 3D motion tracking apparatus.
Install with pip (currently outdated, download package from github instead):
pip install c3d
Or if you'd like to use the bleeding-edge version, just clone the github repository and build and install using the normal Python setup process:
git clone https://github.com/EmbodiedCognition/py-c3d cd py-c3d python setup.py install
Documentation and examples are available in the package documentation.
This package includes scripts for converting C3D motion data to CSV format
(c3d2csv
) and an OpenGL-based visualization tool for observing the motion
described by a C3D file (c3d-viewer
).
To use the C3D library, just import the package and create a Reader
and/or
Writer
depending on your intended usage
import c3d
with open('my-motion.c3d', 'rb') as file:
reader = c3d.Reader(file)
for i, points, analog in reader.read_frames():
print('frame {}: point {}, analog {}'.format(
i, points.shape, analog.shape))
The library also provide functionality for editing both frame and metadata fields; see the package documentation for more details.
The package is tested against the available software examples but may still not support every possible format. For example, parameters serialized in multiple parameters are not handled automatically (such as a LABELS field stored in both POINT:LABELS and POINT:LABELS2). Reading and writing files from a big-endian system is also not supported.
Tests are currently only run on Windows, which means that Linux and Mac users may experience some issues. If you experience issues with a file or feature, feel free to post an issue (preferably by including example file/code/python exception) or make a pull request!
The package is Python only, support for other languages is available in other packages, for example see ezc3d.