Pose timeline¶
Postures and trajectories over time, flat enough to read at a glance. Three views of one pose pipeline, behind one function.
import musicalgestures as mg
video = mg.MgVideo("session.mp4")
video.pose_timeline(view='strip', trajectories='traces') # postures, each with a history
video.pose_timeline(view='room') # skeletons where they stood
video.pose_timeline(view='bands') # an hour compressed to a strip
The three views¶
strip—postures at regular instants, each centred and scaled so two can be compared
even if the dancer was at different distances, with the body's path underneath.

The bundled dancer.avi as a strip: twelve postures, one glance.
room—skeletons at their true positions in the frame, with the route drawn over them
and a dot where each drawn posture stands. Moments are chosen for spatial separation, using
the same reasoning as multishot: evenly spaced ones land on top of each other. This view
earns its keep only when the dancer travels—on a recording made on one spot the
skeletons pile up where the dancer stands, and strip is the view to reach for.
bands—one row per region of the body, carrying its joint angles over time. Dark is
folded, bright is extended, and a held posture is a flat band—which is what posegram
cannot show, since it carries landmark speed and a held limb has none.
Rows read down the body: head, torso, arms, hands, legs. posegram was reordered to match,
so the two can be read row for row.

The same recording as bands: the arm and hand rows carry the dance, the legs hold still, and the white columns are frames the detector missed—gaps stay gaps.
Trajectories on the strip¶
trajectories= |
what it draws |
|---|---|
'traces' |
every landmark, as fading ghost skeletons behind each posture |
'connect' |
head, pelvis and feet threaded through the postures, lane to lane |
'path' |
the room route across the lanes—a schematic, see below |
None |
postures alone |
traces is usually the one you want. The fade is the information: a history at constant
alpha says a limb was in several places without saying which it reached last. It also keeps
density local to each figure, so a busy passage reads as a busy figure rather than as a
scribble across the whole strip—which is what a single line through a fast section becomes.
connect follows averaged groups, in room space. Head, pelvis and feet together carry
what a body does vertically; one landmark cannot. They are averages of several landmarks,
which is steadier than any one. Note that in the strip's body space the pelvis is the
origin by construction—normalise_poses centres on it—so following it there draws a
dead straight line whatever the dancer did. Stability of that kind lives in room coordinates.
The spatial lines have a limit that no setting fixes. They are smoothed harder than the
traces—smooth_spatial defaults to 45 frames against the traces' 9—because they carry
carriage rather than gesture. That works where the body has a stable carriage: standing,
walking, slow phrases. In floor work the head and pelvis genuinely swing through large arcs
many times, and a filter wide enough to calm the lines there is wide enough to eat the arcs
everywhere. Use 'temporal' for fast passages; its density stays local to each figure
instead of crossing the whole strip.
Note also that a smoothing window wider than the gap between two postures flattens that
segment to a constant, so a short recording sampled many times wants smooth_spatial
lowered along with n_samples.
path is a schematic and is drawn as one. Normalising the postures is what removed
their translation, so a room route cannot be to scale in that space.
What is deliberately absent¶
Colour. The skeletons are black. A ramp across the strip says only "this one came later", which the left-to-right order already says, and it costs contrast: a pale figure at the end is harder to read than a black one, and its ghosts nearly invisible.
Titles and captions. The only text is the time axis and its unit—time (s) when a time
base is available, time (frames) when it is not, because 175 is a different claim in each
and nothing else on the figure says which. Everything a caption would say belongs in the
caption of whatever the figure goes into; a plot carrying its own explanation cannot be put
beside another one.
What it cannot do¶
Gaps stay gaps. Frames the detector missed are not interpolated—filling them would
invent posture. In bands they are the white columns that show how much of a row is
actually measured.
It is downstream of the pose detector, which on a dance corpus finds a body in 99 to 100 per cent of frames, including on a dark costume against a black curtain. What it loses is individual landmarks—the wrists most often—and a row that needs one is a gap wherever it is missing.
It assumes a performer who moves. On a seated musician the postures are nearly identical and the strip says little that a single frame would not.
Postures and trajectories over time, flat enough to read at a glance.
Three views of one pose pipeline, behind one function:
strip--- postures at regular instants, each normalised into its own cell, with the body's path drawn underneath. What the body looked like, at times you can point at.room--- skeletons at their true positions in the frame, thin, ramped early to late, with the path threading through them. Where the body went.bands--- one row per region of the body carrying its joint angles over time, so an hour compresses into a strip. What shape the body held, and when it changed.
One function and not three. stroboscope() and multishot() drew the same kind of
picture two ways, and having both meant a reader had to know which before choosing; they
were merged for that reason. Three skeleton views arriving as three names would recreate
the problem knowingly. They share landmarks, visibility gating and normalisation, and
differ only in what they draw.
What each adds over what was already here. pose_waterfall(style='both') draws
skeletons and trajectories in 3D, which must be rotated to be read; strip is flat.
posegram carries landmark SPEED, so a held posture reads as nothing at all; bands
carries configuration, so a held shape is a steady band and a change of shape is an edge.
multishot composites photographs; room draws lines, so many more moments fit before
they occlude one another.
All of it is downstream of the pose detector, which is better at this than expected: measured on a dance corpus it finds a body in 99 to 100 per cent of frames, including on the recording whose dark costume against a black curtain defeats plate differencing. What it loses is individual LANDMARKS --- the wrists most often --- and a row that needs one is a gap wherever it is missing.
Frames it missed are left as GAPS rather than interpolated. Filling them would invent posture, which is worse than admitting there is none, and in the bands view they are the white columns that show how much of a row is actually measured.
normalise_poses ¶
normalise_poses(landmarks, min_visibility=0.0, anchors=None)
Centre each posture on the pelvis and scale it by torso length.
Without this a dancer stepping towards the camera reads as a change of shape, because every coordinate grows at once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
landmarks
|
|
required | |
min_visibility
|
float
|
Landmarks below this are not trusted. A frame whose anchor landmarks fail it becomes a gap. |
0.0
|
anchors
|
tuple
|
|
None
|
Returns:
| Type | Description |
|---|---|
|
np.ndarray: |
|
|
missed**. Gaps are not interpolated: filling them would invent posture. |
Source code in musicalgestures/_posetimeline.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
region_angles ¶
region_angles(normalised)
The mean angle of each region's bones from vertical, per frame, in degrees.
0 is straight down, 90 is horizontal, 180 straight up. Configuration rather than speed: an arm held out stays at 90 for as long as it is held, where a speed measure reads a held limb as nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normalised
|
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, ndarray]
|
region name to |
Source code in musicalgestures/_posetimeline.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
detection_gaps ¶
detection_gaps(landmarks, min_visibility=0.5)
Half-open frame ranges the detector could not place a body in.
Reported rather than smoothed over, because the honest answer to "what was the posture here" is sometimes that nobody knows.
Returns:
| Name | Type | Description |
|---|---|---|
list |
list[tuple[int, int]]
|
|
Source code in musicalgestures/_posetimeline.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
pose_timeline_data ¶
pose_timeline_data(landmarks, min_visibility=0.5)
Everything the three views share: normalised postures, angles, path and gaps.
Raises:
| Type | Description |
|---|---|
ValueError
|
when no frame holds a usable pose. An empty figure reads as "nothing happened" rather than as "nobody was found", and those are different answers. |
Source code in musicalgestures/_posetimeline.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
smooth_trail ¶
smooth_trail(y, window=9)
A moving median along a trail, leaving gaps as gaps.
A curve drawn at every frame is unreadable exactly where the most is happening: on a 30 fps recording the busy half of a section puts thousands of points into a few centimetres of paper, and the limb's real excursion disappears inside its own tremor. A median rather than a mean, because one badly-placed landmark should not drag the curve towards it.
It does not bridge gaps. A window spanning missing frames would invent the posture in between, which is the same fault as interpolating them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y
|
One coordinate along a trail. |
required | |
window
|
int
|
Frames in the window. 0 or 1 returns the trail untouched. |
9
|
Returns:
| Type | Description |
|---|---|
|
np.ndarray: The smoothed trail, NaN preserved where the input was NaN. |
Source code in musicalgestures/_posetimeline.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
connecting_trajectory ¶
connecting_trajectory(normalised, picks, marker=TRAJECTORY_GROUPS, lane=LANE, max_reach=4.0, smooth=SMOOTH_SPATIAL, space='room', raw=None, height=1080)
The course one or more landmark groups take THROUGH the postures, lane to lane.
Drawn over the skeletons so it is visible how one posture connects to the next.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normalised
|
|
required | |
picks
|
The sampled frame indices, ascending. |
required | |
marker
|
An index, a sequence of indices to average, or a mapping of name to indices for several lines at once. Defaults to head / pelvis / feet. |
TRAJECTORY_GROUPS
|
|
lane
|
float
|
Horizontal spacing between postures. |
LANE
|
max_reach
|
float
|
In body space, points beyond this many torso lengths are dropped as detector noise. |
4.0
|
smooth
|
int
|
Moving-median window along each line. 0 draws every frame. |
SMOOTH_SPATIAL
|
space
|
str
|
|
'room'
|
raw
|
|
None
|
|
height
|
int
|
Frame height, to scale room coordinates into the strip. |
1080
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
name to a list of |
Source code in musicalgestures/_posetimeline.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
lane_spacing ¶
lane_spacing(trajectories=None)
How far apart to set the postures.
A fan of ghosts needs room that bare postures do not: at the fixed spacing the busiest figures sat inside the previous one's history, which reads as one confused body rather than as two moments.
Source code in musicalgestures/_posetimeline.py
375 376 377 378 379 380 381 382 | |
posture_traces ¶
posture_traces(normalised, picks, n_ghosts=6, reach=0.5)
Which earlier frames to draw behind each posture, and how faint each should be.
Every landmark leaves a trace, not one --- and the traces FADE, so the direction of time reads. A history drawn at constant alpha is a tangle: it says a limb was in several places without saying which it reached last.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normalised
|
|
required | |
picks
|
The sampled frame indices. |
required | |
n_ghosts
|
int
|
Earlier frames to draw behind each posture. |
6
|
reach
|
float
|
How far back to reach, as a fraction of the gap to the previous sample. Short on purpose: a history covering the whole gap is the scribble this replaced. |
0.5
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
One |
Source code in musicalgestures/_posetimeline.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | |
render_pose_timeline ¶
render_pose_timeline(data, view='strip', n_samples=12, raw=None, width=1920, height=1080, times=None, cmap='viridis', dpi=200, trajectories=None, markers=TRAJECTORY_GROUPS, smooth=SMOOTH, space='room', n_ghosts=6, smooth_spatial=SMOOTH_SPATIAL)
Draw one of the three views. Returns a matplotlib figure.
Source code in musicalgestures/_posetimeline.py
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | |
pose_timeline ¶
pose_timeline(landmarks, view='strip', n_samples=12, min_visibility=0.5, times=None, width=1920, height=1080, cmap='viridis', dpi=200, trajectories=None, markers=TRAJECTORY_GROUPS, smooth=SMOOTH, space='room', n_ghosts=6, smooth_spatial=SMOOTH_SPATIAL)
Postures and trajectories over time, as a matplotlib figure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
landmarks
|
|
required | |
view
|
str
|
|
'strip'
|
n_samples
|
int
|
Postures to draw, for |
12
|
min_visibility
|
float
|
Landmarks below this are not trusted. |
0.5
|
times
|
optional
|
Seconds per frame, for a real time axis. |
None
|
width, height
|
int
|
The frame's size, for the |
required |
trajectories
|
str or sequence
|
For |
None
|
markers
|
tuple or int
|
Landmark to follow for |
TRAJECTORY_GROUPS
|
smooth
|
int
|
Moving-median window for the temporal traces, in frames. Defaults to 9, about a third of a second at 30 fps; 0 draws every frame. |
SMOOTH
|
smooth_spatial
|
int
|
The window for the spatial lines, which want a wider one:
they carry carriage rather than gesture, and at the traces' window they thrash
through a fast passage and cross other figures. Defaults to 45, about a second
and a half at 30 fps. A window wider than the gap between two postures
flattens that segment to a constant, so a short recording sampled many times
wants it lowered along with |
SMOOTH_SPATIAL
|
cmap
|
str), dpi (int
|
Appearance. |
'viridis'
|
Returns:
| Type | Description |
|---|---|
|
matplotlib.figure.Figure |
Raises:
| Type | Description |
|---|---|
ValueError
|
when no frame holds a usable pose, or |
Source code in musicalgestures/_posetimeline.py
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | |
mg_pose_timeline ¶
mg_pose_timeline(self, view='strip', n_samples=12, min_visibility=0.5, landmarks=None, times=None, cmap='viridis', dpi=200, trajectories=None, markers=TRAJECTORY_GROUPS, smooth=SMOOTH, smooth_spatial=SMOOTH_SPATIAL, target_name=None, overwrite=True, **pose_kwargs)
Postures and trajectories over time. See pose_timeline.
Landmarks come from a cached pose() result when there is one, exactly as posegram
resolves them, and otherwise from a fresh extraction.
Source code in musicalgestures/_posetimeline.py
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | |