A modular toolbox for dance motion analysis, feature extraction, and tempo estimation
Project description
DanceIR: Dance Information Retrieval Toolbox
A modular Python toolbox for dance motion analysis, feature extraction, and tempo estimation from 2D keypoint data.
This toolbox implements a kinematic anchor–based framework for estimating musical tempo from dance movement, as described in the following manuscript currently under review:
Estimating Music Tempo from Dance Movement Using Kinematic Rhythmic Anchors (under review)
Features
- Multi-anchor dance tempo estimation: Robust dance tempo estimation using multiple body segments (hands, feet, torso)
- COCO-format keypoint support: Load and process standard 2D keypoint formats
- Feature extraction: Center of mass, anchor detection, and energy-based features
- Signal preprocessing: Detrending, normalization, and filtering utilities
- Evaluation metrics: Octave-invariant metric for dance tempo estimation evaluation
Installation
From PyPI
pip install danceir
From source
git clone https://github.com/sagar0dutta/danceir.git
cd danceir
pip install -e .
Optional dependencies
For demo notebooks and video processing:
pip install danceir[demo]
For development:
pip install danceir[dev]
Quick Start
Basic Tempo Estimation
import numpy as np
from danceir.io import KeypointLoader
from danceir.pipelines import estimate_tempo_from_keypoints
# Load keypoint data (COCO format)
loader = KeypointLoader()
keypoints_data = loader.load_keypoints_pickle("keypoints.pkl")
keypoints_2d = loader.extract_all_keypoints_2d(keypoints_data)
# Shape: (num_frames, num_joints, 2) where last dim is [x, y]
# Estimate tempo
result = estimate_tempo_from_keypoints(
keypoints_2d,
marker_groups=[(9, 10), (15, 16)], # both hands, both feet
axis='y',
use_com=True, # Include torso center of mass
fps=60.0
)
# Get results
tempo_info = result['combined_anchors']
print(f"Estimated tempo: {tempo_info['gtempo']} BPM")
print(f"Best segment: {tempo_info['best_segment']}")
Evaluation
from danceir.evaluation import dance_tempo_evaluation
# Compare estimated tempo with reference
ref_tempo = 120.0 # Ground truth BPM
est_tempo = tempo_info['gtempo']
eval_result = dance_tempo_evaluation(ref_tempo, est_tempo)
print(f"Accuracy: {eval_result.accuracy}%")
print(f"Mean DTS: {eval_result.mean_dts:.3f}")
Keypoint Format
DanceIR expects COCO-format 2D keypoints:
- Input shape:
(num_persons, num_frames, num_joints, 3) - Last dimension:
[x, y, confidence] - Joint indices: 0=nose, 1=left_eye, ..., 9=left_wrist, 10=right_wrist, ..., 15=left_ankle, 16=right_ankle
API Overview
Main Pipeline
estimate_tempo_from_keypoints(): High-level tempo estimation from keypoints
I/O
KeypointLoader: Load COCO-format keypoint data from pickle filesAnchorIO: Save/load anchor sequencesPathManager: Manage data paths
Features
compute_com_variants(): Compute center of mass (hips, shoulders, torso)detect_segment_anchor(): Detect anchors from motion signalsAnchorExtractor: High-level anchor extraction interfaceEnergyExtractor: Energy-based feature extraction
Analysis
estimate_dance_tempo(): Multi-anchor tempo estimationcompute_tempogram(): Compute tempogram from anchor signalscompute_alignment(): Align signals with sinusoidal templates
Evaluation
dance_tempo_evaluation(): Compute Octave-invariant metrics
Requirements
- Python >= 3.8
- numpy >= 1.20.0
- scipy >= 1.7.0
- librosa >= 0.9.0
Documentation
Full documentation:
Examples
See the demo/ directory for Jupyter notebook examples:
- Demo.ipynb: Complete tutorial with tempo estimation from keypoint files and video processing with MediaPipe pose estimation
- Basic tempo estimation from keypoint files
- Video processing with MediaPipe pose estimation
The demo notebook demonstrates:
- Loading COCO-format keypoint data
- Extracting multi-anchor features (hands, feet, torso)
- Running tempo estimation pipeline
- Evaluating results with reference tempos
- Processing videos with MediaPipe for pose estimation
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Issues
Report bugs or request features on GitHub Issues.
Author
Sagar Dutta - sagar0dutta@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file danceir-1.0.0.tar.gz.
File metadata
- Download URL: danceir-1.0.0.tar.gz
- Upload date:
- Size: 34.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d51c07942fac48067ce7717c94ed42d6668d53e0808e09cc01ba6a78b6fb2eb
|
|
| MD5 |
e0459e6252a327f13d4c8b674fc0433a
|
|
| BLAKE2b-256 |
082834cdab5bde44e53615759871c1e58e9a415c745c401feaa33c54054b6129
|
File details
Details for the file danceir-1.0.0-py3-none-any.whl.
File metadata
- Download URL: danceir-1.0.0-py3-none-any.whl
- Upload date:
- Size: 41.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
986677b9f8c412b68eff3176bfed45434165a90c1e22796e9378f7d5e174e7f2
|
|
| MD5 |
c383c71bb3167ed28cd03aaef843f080
|
|
| BLAKE2b-256 |
369d3d3858aaa76c2ea6dbe5fbb9948023928ef79b22d025c77209934f836896
|