Pose Visualize¶
render_average_pose ¶
render_average_pose(data, names, connections, width, height, fps, avg_frame, target_name, overwrite=True, fmin=0.2, fmax=8.0, style='both')
Render the average pose of the whole video, with per-marker quantity of motion (colour + label) and dominant frequency (label) annotated.
style matches the video: 'both' draws markers + skeleton lines, 'markers' draws
only the markers, 'skeleton' draws only the connecting joint lines. Per-marker labels
are shown in all cases.
Returns an MgImage, or None if there are too few frames.
Source code in musicalgestures/_pose_visualize.py
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 132 133 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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
render_trajectories ¶
render_trajectories(data, names, width, height, fps, target_name, overwrite=True, background='black', labels=False)
Render every marker's spatial trajectory across the whole video.
background chooses the PNG background: 'black' (default), 'white', or
'transparent' (so the PNG can be overlaid on the original video later). Set
labels=True to annotate each trajectory with its marker name (off by default).
Returns an MgImage, or None if there are too few frames.
Source code in musicalgestures/_pose_visualize.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
render_pose_waterfall ¶
render_pose_waterfall(data, names, width, height, fps, target_name, overwrite=True, style='trajectories', connections=None, n_samples=40, markers=None, color_by=None, cmap='hsv', dpi=200, elev=20, azim=-60, lw=1.0, axes=True, crop=False)
Render a 3D spatio-temporal waterfall of the pose, cascading along the time (depth) axis —
a pose-based counterpart to silhouette_waterfall().
style selects what is drawn:
'trajectories'(default): each marker's path is a continuous line through (x, time, y).'markers': the markers themselves are scattered atn_samplestime slices.'skeleton': the skeleton joint lines are drawn atn_samplestime slices.'both': markers + skeleton at each time slice.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
list
|
Collected pose rows |
required |
names
|
list
|
Marker names (length n_points). |
required |
width
|
int
|
Frame width in pixels (used to scale normalised coords). |
required |
height
|
int
|
Frame height in pixels (used to scale normalised coords). |
required |
fps
|
float
|
Frames per second (for the time axis). |
required |
target_name
|
str
|
Output PNG path. |
required |
overwrite
|
bool
|
Overwrite or auto-increment the filename. Defaults to True. |
True
|
style
|
str
|
|
'trajectories'
|
connections
|
list
|
Skeleton connection pairs (indices); required for the
|
None
|
n_samples
|
int
|
Number of time slices for the marker/skeleton styles. Defaults to 40. |
40
|
markers
|
list
|
Subset of marker names or indices to draw. Defaults to all. |
None
|
color_by
|
str
|
|
None
|
cmap
|
str
|
Matplotlib colormap. Defaults to 'hsv'. |
'hsv'
|
dpi
|
int
|
Output DPI. Defaults to 200. |
200
|
elev
|
float
|
3D elevation angle. Defaults to 20. |
20
|
azim
|
float
|
3D azimuth angle. Defaults to -60. |
-60
|
lw
|
float
|
Line width. Defaults to 1.0. |
1.0
|
axes
|
bool
|
Draw the axes and tick labels. Set to False for a clean render with all axes and text removed. Defaults to True. |
True
|
crop
|
bool
|
Tighten the spatial axis limits to the actual marker extent and trim the surrounding whitespace, so the figure shows mostly the data. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
MgFigure |
the 3D waterfall figure, or None if there are too few frames. |
Source code in musicalgestures/_pose_visualize.py
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 289 290 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 373 374 375 376 377 378 379 380 381 382 383 384 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 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
render_segment_circular ¶
render_segment_circular(data, names, connections, width, height, fps, target_name, overwrite=True, segments=None, n_bins=36, cmap='viridis', dpi=200, ncols=6)
Circular (polar) motion plots and statistics for every body segment.
A segment is the bone between two connected joints. For each segment this computes the per-frame orientation angle and draws a polar rose histogram of the angle distribution with the mean-direction resultant vector overlaid, annotated with the segment's circular statistics. A CSV of the per-segment statistics is saved alongside the image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
list
|
Collected pose rows |
required |
names
|
list
|
Marker names (length n_points). |
required |
connections
|
list
|
Segment connection pairs (joint-index tuples). |
required |
width
|
int
|
Frame width in pixels (to scale coordinates). |
required |
height
|
int
|
Frame height in pixels (to scale coordinates). |
required |
fps
|
float
|
Frames per second (for angular speed). |
required |
target_name
|
str
|
Output PNG path. |
required |
overwrite
|
bool
|
Overwrite or auto-increment the filename. Defaults to True. |
True
|
segments
|
list
|
Subset of connections (as |
None
|
n_bins
|
int
|
Number of angular bins in each rose. Defaults to 36 (10° bins). |
36
|
cmap
|
str
|
Matplotlib colormap for the bars (by bin count). Defaults to 'viridis'. |
'viridis'
|
dpi
|
int
|
Output DPI. Defaults to 200. |
200
|
ncols
|
int
|
Number of columns in the subplot grid. Defaults to 6. |
6
|
Returns:
| Name | Type | Description |
|---|---|---|
MgFigure |
the grid of circular plots (per-segment stats in |
|
|
are too few frames. |
Source code in musicalgestures/_pose_visualize.py
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 | |
pose_center ¶
pose_center(data, names)
Centre pose data on its global centroid (a 2D port of the MoCap Toolbox mccenter).
Computes a single offset per coordinate dimension — the mean of the per-marker temporal means (missing detections ignored) — and subtracts it from every marker so the overall spatiotemporal centroid sits at the origin (0, 0).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
list
|
Collected pose rows |
required |
names
|
list
|
Marker names (length n_points). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
Source code in musicalgestures/_pose_visualize.py
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | |
render_pose_center ¶
render_pose_center(data, names, width, height, target_name, overwrite=True, cmap='hsv', dpi=200)
Centre the pose data (see :func:pose_center) and plot the centred marker trajectories.
Returns an MgFigure whose .data holds the centred coordinates and the removed offset, or
None if there are too few frames.
Source code in musicalgestures/_pose_visualize.py
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 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | |
pose_distance ¶
pose_distance(data, names, width, height)
Per-marker cumulative distance travelled (a 2D port of the MoCap Toolbox mccumdist).
Sums the frame-to-frame Euclidean displacement of each marker (in pixels) and accumulates it over time. Gaps from missing detections contribute no distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
list
|
Collected pose rows |
required |
names
|
list
|
Marker names (length n_points). |
required |
width
|
int
|
Frame width in pixels (to scale the normalised coordinates). |
required |
height
|
int
|
Frame height in pixels (to scale the normalised coordinates). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
Source code in musicalgestures/_pose_visualize.py
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 | |
render_pose_distance ¶
render_pose_distance(data, names, width, height, fps, target_name, overwrite=True, cmap='hsv', dpi=200)
Plot per-marker cumulative distance travelled over time plus a ranked total per marker.
Returns an MgFigure (.data holds the totals, average, and cumulative curves) and saves a
CSV of the per-marker totals; None if there are too few frames.
Source code in musicalgestures/_pose_visualize.py
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 | |