Pose Visualize¶
Auto-generated documentation for musicalgestures._pose_visualize module.
- Mgt-python / Modules / Musicalgestures / Pose Visualize
pose_center¶
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).
Arguments¶
datalist - Collected pose rows[time_ms, x0, y0, ...](normalised coords).nameslist - Marker names (length n_points).
Returns¶
tuple-(centered, offset, times)wherecenteredis a (T, n, 2) array of centred normalised coordinates (NaN for missing),offsetis the (x, y) centroid that was removed, andtimesis the per-frame time in seconds.
pose_distance¶
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.
Arguments¶
datalist - Collected pose rows[time_ms, x0, y0, ...](normalised coords).nameslist - Marker names (length n_points). width, height (int): Frame size in pixels (to scale the normalised coordinates).
Returns¶
tuple-(cumulative, total, average, times)wherecumulativeis a (T-1, n) array of cumulative distance per marker (pixels),totalis the per-marker total (n,),averageis the mean total across markers, andtimesare the per-frame times (s).
render_average_pose¶
def 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.
render_pose_center¶
def 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.
render_pose_distance¶
def 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.
render_pose_waterfall¶
def 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.
Arguments¶
datalist - Collected pose rows[time_ms, x0, y0, x1, y1, ...](normalised coords).nameslist - Marker names (length n_points). width, height (int): Frame size in pixels (used to scale normalised coords).fpsfloat - Frames per second (for the time axis).target_namestr - Output PNG path.overwritebool, optional - Overwrite or auto-increment the filename. Defaults to True.stylestr, optional -'trajectories'(default),'markers','skeleton', or'both'.connectionslist, optional - Skeleton connection pairs (indices); required for the'skeleton'/'both'styles.n_samplesint, optional - Number of time slices for the marker/skeleton styles. Defaults to 40.markerslist, optional - Subset of marker names or indices to draw. Defaults to all.color_bystr, optional -'marker'(one colour per marker) or'time'(colour by time). Defaults to None ("auto"): 'marker' for trajectories, 'time' for the slice styles.cmapstr, optional - Matplotlib colormap. Defaults to 'hsv'.dpiint, optional - Output DPI. Defaults to 200.elevfloat, optional - 3D elevation angle. Defaults to 20.azimfloat, optional - 3D azimuth angle. Defaults to -60.lwfloat, optional - Line width. Defaults to 1.0.axesbool, optional - Draw the axes and tick labels. Set to False for a clean render with all axes and text removed. Defaults to True.cropbool, optional - 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.
Returns¶
MgFigure- the 3D waterfall figure, or None if there are too few frames.
render_segment_circular¶
def 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.
Arguments¶
datalist - Collected pose rows[time_ms, x0, y0, ...](normalised coords).nameslist - Marker names (length n_points).connectionslist - Segment connection pairs (joint-index tuples). width, height (int): Frame size in pixels (to scale coordinates).fpsfloat - Frames per second (for angular speed).target_namestr - Output PNG path.overwritebool, optional - Overwrite or auto-increment the filename. Defaults to True.segmentslist, optional - Subset of connections (as(a, b)index tuples) to plot. Defaults to all connections.n_binsint, optional - Number of angular bins in each rose. Defaults to 36 (10° bins).cmapstr, optional - Matplotlib colormap for the bars (by bin count). Defaults to 'viridis'.dpiint, optional - Output DPI. Defaults to 200.ncolsint, optional - Number of columns in the subplot grid. Defaults to 6.
Returns¶
MgFigure- the grid of circular plots (per-segment stats in.data), or None if there are too few frames.
render_trajectories¶
def 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.