-
Notifications
You must be signed in to change notification settings - Fork 10
Guided Tour: Motion analysis
This is a part of the MiningSuite Guided Tour.
This section gives a brief tour of features available in the PatMinr package, with is mainly an integration of the MoCap Toolbox.
The list of commands is also available in the script phy.mocap
.
NB: The current GitHub repository version of MiningSuite is required.
Load a mocap file (from Qualisys) and visualise the movement (a person walking):
p = phy.point('walk.tsv')
You can turn off the display of the index numbers:
phy.pref('DisplayIndex',0)
p
By default, the motion visualisation is real-time. Frames of the video are dropped in order to ensure the real-time quality. You can toggle off the frame drop. Since all frames are displayed, the video is slower.
phy.pref('DropFrame',0)
p
To revert to default options:
phy.pref('Default')
Some markers positions were not properly recorded. The missing points can be reconstructed:
p = phy.point('walk.tsv','Fill')
The mocap data can be turned into a signal using sig.signal
. Let's select marker #3 and the third spatial dimension:
s = sig.signal(p,'Point',3,'Dim',3)
We can select a particular point of time (or temporal region):
p = phy.point('walk.tsv','Fill','Extract',160,160,'sp')
The points can be connected together to form a stick figure:
p = phy.point('walk.tsv','Fill','Connect',mapar)
We can represent a dancing stick figure in a "velocity space":
d2 = phy.point('dance.tsv','Connect',mapar)
d2v = phy.point('dance.tsv','Velocity')
d2v = phy.point('dance.tsv','Velocity','Connect',mapar)
as well as an "acceleration space":
d2a = phy.point('dance.tsv','Acceleration','Connect',mapar)
We can observe the three figures (position, velocity, acceleration) synced together:
s = phy.sync(d2,d2v,d2a)
Here also we can observe this visualisation without dropping frames:
phy.pref('DropFrame',0)
s
phy.pref('Default')
We can represent the velocity and acceleration in a phase plane:
sv = sig.signal(d2v,'Point',[1;19;25],'Dim',3)
sa = sig.signal(d2a,'Point',[1;19;25],'Dim',3)
s = sig.sync(sv,sa)
s.phaseplane
By computing the norm of the velocity (considered here as a simple time derivation of the positions) and summing the values altogether, we compute the total distance traveled by each marker:
d2v = phy.point('dance.tsv','Velocity','Connect',mapar,'PerSecond',0,'Filter',0);
sv = sig.signal(d2v,'Point',[1;19;25])
n = sig.norm(sv,'Along','dim')
sig.cumsum(n)
We can use sig.autocor
from SigMinr to detect periodicities in the movement:
d2m1 = sig.signal(d2,'Point',1)
sig.autocor(d2m1,'Max',2)
d2m1 = sig.signal(d2,'Point',1,'Dim',3)
sig.autocor(d2m1,'Max',2)
sig.autocor(d2m1,'Max',2,'Enhanced')
sig.autocor(d2m1,'Max',2,'Frame','FrameSize',2,'FrameHop',.25,'Enhanced')
We can use mus.tempo
from MusMinr to perform tempo estimation on the movement:
[t ac] = mus.tempo(d2m1)
[t ac] = mus.tempo(d2m1,'Frame')
Any time of statistics can be performed on the temporal signals of each marker:
d = phy.point('dance.tsv');
sd = sig.signal(d,'Point',[1;19;25])
sig.std(sd)
sig.std(sd,'Frame','FrameSize',2,'FrameHop',.25)
Here is for instance a comparison of the vertical skewness of particular markers for dancing and walking figures:
sd = sig.signal(d,'Point',[1;9;19;21;25],'Dim',3)
w = phy.point('walk.tsv');
sw = sig.signal(w,'Point',[1;9;19;21;25],'Dim',3)
sig.skewness(sd,'Distribution')
sig.skewness(sw,'Distribution')
phy.segment
transforms a trajectory of points into a temporal motion of interconnected segments.
segmindex = [0 0 8 7 6 0 8 7 6 13 12 10 11 3 2 1 11 3 2 1];
ss = phy.segment('walk.tsv',j2spar,segmindex,'Reduce',m2jpar,'Connect',japar,'Fill')
From that representation, we can compute for instance potential energy of each segment, and sum them together:
pe = phy.potenergy(ss)
sig.sum(pe,'Type','segment')