A Python automation tool for recording OpenCap motion capture animations using the OpenCap web viewer.
- Automated recording of OpenCap motion capture comparisons
- Multiple camera angle recordings
- Customizable wait times and recording loops
- Automatic file handling and cleanup
- Python 3.7+
- Google Chrome browser
- Internet connection (to access the OpenCap viewer website)
- Create and activate a Python virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install Python dependencies:
pip install -r requirements.txtUse the Python script to automate the recording process:
python automation.py path/to/first.json path/to/second.json output_video.webmOptional arguments:
--wait: Adjust loading wait time (default: 5 seconds)--loops: Number of camera angle changes (default: 3)
Example:
python automation.py test1.json test2.json comparison.webm --wait 10 --loops 4The automated recording cycles through these views:
- Front view (0°)
- Side view (90°)
- Back view (180°)
- High angle diagonal view (45°)
The script expects OpenCap JSON files with the following structure:
{
"time": [...],
"bodies": {
"body_name": {
"translation": [...],
"rotation": [...],
"attachedGeometries": [...]
}
}
}-
If the video doesn't download:
- Check Chrome's download permissions
- Ensure the output directory is writable
- Verify your internet connection
-
If models don't appear:
- Verify JSON file format
- Check that the files are valid OpenCap JSON files
- Increase the wait time using
--wait
-
If camera controls don't work:
- Ensure the browser window is focused
- Check that the website has loaded properly
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request