Repository navigation
[1.33.0] — 2026-12-03
- Documentation: README gains "What you can reuse" and "What it does not do", naming Kinetics Toolkit, PyEyesWeb and librosa as the tools for what this package leaves out (2026-09-18).
- Documentation: every docstring parameter list matches its function's signature (grouped entries such as
start, endare split, one per parameter), and the documentation site builds withmkdocs build --strict, locally and in CI (2026-12-03).
The unreleased features below were developed for and are exercised end to end by
avsegmenter, which segments concert and lecture recordings.
Fixed
- The agreement rule of
motiontempo(),tempo_similarity()and_fold.tempo_over_timeis
half of the windows, not two thirds. Returned values change: a recording in which between
half and two thirds of the windows agree now has a tempo where it had NaN. A tempo that
fluctuates with its phrases often has a third of its windows off the median, and a recording
without a tempo stays below a half (the bundled dancer has 31%). The price is with short
recordings: windows of smooth unpulsed motion reach one half in about one recording of a
minute in ten and one of two minutes in forty.min_sharerestores the stricter rule. beat_statistics(source='motion')called the rate of its motion onsets a tempo. It is a
count of the peaks the onset detector accepts: 191.5 per minute on the bundled pianist, where
signals with the same broad spectrum and no order give 211 to 234 and the motion's periodic
levels lie at 113, 212 and 324. The figure says "motion onsets per minute",datagains
onset_rate(the same value astempo), and the docstring says what the number is.motiondescriptors()called the largest bin of the whole recording's spectrum "the dominant
periodicity of the motion". It is the bottom of a spectrum that falls with rate: 21.0 per
minute for the dancer and 13.5 for the pianist, where signals with the same broad spectrum
and no order put theirs below 30 per minute in 97% and 94% of cases. The value is unchanged;
the docstring and the figure's label say what it is.- The per-marker dominant frequency of the average-pose figure read the encoder's rhythm. A
repeated frame stops every marker for one frame, which at every sixth frame of 30 is 5 per
second. The speed is now cleaned withremove_frame_lockedfirst. motiontempo()reported the encoder's rhythm as the motion tempo. Its returned values
change, and so do its defaults. Frame differences of compressed video jump at every keyframe
and drop at every repeated frame, on an exact frame lattice, and that was the dominant
frequency: 125 BPM on the bundleddancer.avi(a keyframe every 12 frames at 25 fps), 300 BPM
onpianist.avi(a near-repeated frame every sixth)._motiontempo.remove_frame_lockednow
takes such lattices out of the signal (clean=True, the default inquantity_of_motion). The
tempo is then estimated in windows (_fold.tempo_over_time, 12 s windows 4 s apart, 40 to 240
BPM) and reported when half of the windows agree to within 8%:tempo_bpmand
dominant_frequencyare the median, or NaN with aRuntimeWarningand areason, anddata
gainstempo_curve,tempo_times,tempo_quartiles,tempo_shareandframe_locked. The
defaults offminandfmaxmove from 0.2 and 8 Hz to 40 and 240 per minute. The dancer now
returns no tempo and the pianist 109 BPM.tempo_similarity()returned a motion tempo for motion that has none (125 BPM for the
dancer). Its motion tempo now comes from the same windowed estimate; without one,
motion_tempo_bpm,tempo_ratioandtempo_agreementare NaN.beat_statistics(source='motion'),
phase_synchrony(),dynamics_coupling()andmotiondescriptors()read the same cleaned
signal, so their numbers change as well. The quantity of motion written bymotion()is
unchanged.get_framecountfailed when ffprobe printed a message before the count: on Ubuntu's ffprobe a
WebM with Opus audio gives "Error parsing Opus packet header." on the same pipe as the video
stream's count, and the whole output went toint(). The count is now read from its own line.
This was the ten failing tests of the Ubuntu CI jobs.- MediaPipe segmentation aborted the process on frame widths that are not a multiple of four,
the bundled 518-pixel-widedancer.aviamong them, as soon as it found a person:
_spacetime._make_segmenternow pads the frame to the next multiple and cuts the mask back.
This affectedsilhouette_waterfall,spacetime_volumeandmultishot(segmenter='mediapipe'). - The
videogram_*tracks ofextract_trackswere motiongrams (#383): they averaged the motion
frame, not the picture. They are now written asmotiongram_v.u1/motiongram_h.u1under
motiongram_*keys, and true videograms come from one extra ffmpeg filter graph
(extract_videograms, on by default,videograms=Falseto skip), trimmed so that column j
lines up with motion frame j.read_columns,build_pyramidandrender_timelinetake both
names; an analysis folder written before the rename serves its motion means under
motiongram_*and, undervideogram_*, with a warning that says what they are. _mocap.read_c3dimportedMgErrorfrom_utils, where it does not live; mypy on master failed on it._tracks.read_columnsfailed on any recording long enough to need a pyramid level.
extract_tracksandextract_tracks_parallelwrite the base videograms only, and
read_columnsmemory-mappedvideogram_v.L<k>.u1without checking it existed, so the first
read of a real concert raisedFileNotFoundErrorunless the caller knew to run
build_pyramidfirst. It now builds the levels on first use.
Added
- The levels of a motion signal. Music runs at several temporal levels at once, and
_levels.motion_levels(andMgVideo.motion_levels()) lists every periodicity in a motion
signal from tens of seconds to eight per second, each withperiod,strengthagainst a
stated null (signals with the same broad spectrum and random phases),presence(the share of
windows in which it stands out),frame_locked(it falls on the encoder's lattice or a
harmonic) andsupported(the recording's sound has it too, fromsound_levels), and groups
levels at 3/2, 2, 3 and 4 into metrical families. It promotes none to the tempo. The fast
range is read by_fold.window_spectra, the windowsmotiontempo()reads, and the slow range
by_fold.slow_candidates, the autocorrelationestimate_period(search='slow')reads. On the
bundled examples: the dancer has no level in the beat range and one slow level, the music's
repetition at 21.4 s, which its motion follows below chance; the pianist has a beat at 113 per
minute (111 in its sound) and levels at twice and three times that, one family. - The motion tempogram.
motion_tempogramandmotion_tempogram_view(and
MgVideo.motion_tempogram()) draw the windowed spectrum over time on a logarithmic rate axis,
with the levels marked and the sound's tempogram, measured the same way, beneath it. - Slow periods.
estimate_period(search='slow'), and with itfold_signal,folded_viewand
MgVideo.folded(), look for the repetition of a whole passage, from 8 s to two fifths of the
signal, in the autocorrelation of the smoothed signal, tested against surrogates with the same
smoothness (alpha; None returns the strongest lag as a candidate).fold_signalkeeps a last
row that is at least half filled, with NaN where the signal has ended.MgVideo.folded()takes
cleanin place ofdespike. - The two bundled videos are reference cases (
tests/test_reference_examples.py, marked
slow) and are described once, on the examples page. - Four pictures of where, when, and both. Spatial:
time_compositeand
MgVideo.time_composite()paint every pixel that moved in the hue of the moment it moved,
over the average frame, with a colour bar for time; the strongest moment wins where a pixel
moved more than once (combine='latest'for the last), andmask=takes aMaskTrackor a
silhouette function. Temporal:_raster.activity_rasterdraws one labelled row per person
(mask_activity, from aMaskTrack) or per body region (region_activity, from pose
landmarks), scaled per row by default, with missing values drawn as missing; and
_fold.fold_signal,folded_viewandMgVideo.folded()stack a motion signal with one
period per row, the period given or estimated byestimate_period, which raises when the
dominant frequency is not a peak. Spatial-temporal:_videograms.slitscanand
MgVideo.slitscan()keep one pixel column or row of every frame, at a given position, at the
strongest motion or following a tracked point. All read in one pass with constant memory and
sample long recordings._motiontempo.quantity_of_motionis the signalmotiontempo()already
computed, now callable. - Silhouette panels and held objects —
_spacetime.silhouette_panelsand
MgVideo.silhouette_panels()lay one person out as numbered, timed panels at regular intervals
or given times, all under one crop, as a dark silhouette on a paper-coloured ground with an
optional stick figure from pose landmarks.held_silhouette(person, frame, plate)adds what the
person holds (whatever differs from the room plate next to the body),held_axisreduces that
object to one line segment andheld_axesruns it through a video;silhouette_waterfalland
spacetime_volumetakeheld=True._plate.room_plate_colouris the colour room plate that
multishotandMgVideo.plate()already built, now in one place. A panel without a person stays
empty and is counted. pose_timeline(view='marey')— every posture as thin light lines on black at its true size
and place, each movedsteppixels to the right of the one before, with a time axis and an
optional(frames, 4)array ofsegments(a held instrument's axis) in a second colour;
everydraws every n-th frame, andMgVideo.pose_timeline(view='marey', held=True)finds the
segments itself.- Masks per object (#388) — new
_masksmodule.track_masksfollows each person (YOLO
prompts) or each given box through a video with SAM 2 at 2 fps in one-minute chunks, with
re-detection at chunk starts, and saves aMaskTrack(bit-packed.npz).mask_holdingcounts
lost, jumping, merged and drifting masks and the longest clean run;mask_motiongives the
frame difference inside each mask beside the whole frame.MgVideo.motion(mask=, mask_object=)
restricts quantity, centroid and area of motion, the motiongrams and the motion video to one
mask. SAM 2 is installed from its repository, not as an extra, since it is not on PyPI under
its own name. - People on stage — new
_performersmodule.detect_peopleruns a YOLO person detector
(ultralyticsextra) at a low frame rate through an ffmpeg pipe;on_stagekeeps the boxes
whose heads are in the upper part of the frame and drops the audience cut off by the bottom
edge;performer_countreports how many perform in a span as a high percentile of the
per-frame counts (the wide shots), with median and maximum beside it. Exact for a soloist,
a duo and a five-piece band from an operated concert camera; a choir is under-counted. performer_count(..., stat="typical")takes the median over framings instead of the widest, for
lecture halls where the widest framings are the hall and the slides;detect_peopleand
make_proxy/camera_motiontakeffmpeg_input_args(e.g.["-hwaccel", "cuda"]).- Camera cuts and PTZ — new
_cameramodule.camera_motionlabels each sample of a video
still,movingorcutfrom ORB matches and a partial-affine RANSAC fit between consecutive
frames of a small 2 fps proxy (make_proxy), and returns cuts, shots and the share of time in
each state;still_runsgives the framings (still runs between moves and cuts);
camera_state_atsamples the state at arbitrary times, so motion measures can exclude camera
motion.performer_count(..., camera=...)counts per framing (the 75th percentile of each, the
widest framing being the estimate), which is what makes the count right with an operated camera. tracks.json(and the dict both extractors return) carriesanalysis_dir, so a caller can
go fromextract_tracks_parallel(...)toread_columns/check_trackswithout
reconstructing theanalysis/<stem>path convention.extract_wavis exported from the package root.- Events against events — new
_eventsmodule.event_alignmentmeasures how far each
event of one stream (strokes, footfalls, looks) falls from the nearest event of another
(note onsets, beats, cues) against uniformly placed surrogate references, and says whether
the two attract, avoid or sit at chance, with the signed lag of the nearest reference
telling which came first;event_xcorrcorrelates the binned event trains. On the
painter–pianist session this separated three takes no envelope correlation had. - Cross-recurrence —
_correlate.cross_recurrence: recurrence rate at a fixed radius
quantile, determinism, mean line length and the diagonal recurrence profile of two series,
each against circular-shift surrogates, so a high determinism from two smooth series is not
mistaken for coordination. - The painting as a time series — new
_canvasmodule.painting_contentreduces a
canvas video to one hand-free median frame per second and measures painted share, monotone
coverage, chromatic share, the hue histogram (drawn as a colourgram bycolourgram_image),
warm/cool balance, edge density, composition (composition: paint centre and spread,
left–right symmetry, edge-orientation histogram and anisotropy) and a dominant-colour
palette per minute. Bound onMgVideoaspainting(). - Head turns from the IMU —
_pupillabs.head_turns: yaw relative to a running median,
and the spans where the head is turned away from what the wearer has been facing. - TRC and C3D readers —
read_trcandread_c3dbesideread_qtm_tsv, so Qualisys,
OptiTrack, Vicon, Theia3D, Pose2Sim and OpenCap exports all land on the same trajectory
contract:(marker_names, data, fs)withdataof shape(frames, markers, 3), gaps as
NaN (never zeros) and positions converted onto millimetres from the file's declared unit.
read_c3drides the optionalezc3dpackage, added to the[c3d]extra beside the
pure-Pythonc3dwriter dependency; analog channels and events are declaredly not read. - FreeMoCap reader —
read_freemocapreads a FreeMoCap recording folder onto the same
trajectory contract: the body trajectories fromoutput_data/mediapipe_body_3d_xyz.npy
(millimetres and NaN gaps already, passed through unchanged) with MediaPipe's 33 landmark
names, and the frame rate derived from the recording's own timestamp records the way
FreeMoCap itself derives it —Nonewith a warning when no record exists, never a guessed
default. Hands, face, centre of mass and reprojection errors are declaredly not read.