gestures

[unmaintained] PoC for motion gesture detection from webcam input
Log | Files | Refs | README | LICENSE

commit a954048024e8cdf84d0b143c24a8f89b777decfc
parent 4339216c1fa0ca4de7fecc9800a640ee0a1a7bf0
Author: Stefan Koch <taikano@lavabit.com>
Date:   Fri,  7 Jun 2013 21:53:15 +0200

added some fixes

Diffstat:
Mmodels.py | 6+++++-
Mtrack2.py | 4+++-
2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/models.py b/models.py @@ -49,6 +49,10 @@ def emission_matrix(gesture): return B +def initial_vector(gesture): + vec = [0 for i in range(4)] + vec[gesture[0]] = 1 + return vec # Construct parameters models = [] @@ -58,7 +62,7 @@ for gesture in gestures: # transition matrix A = transition_matrix(gesture[0]) B = emission_matrix(gesture[0]) - pi = [1, 0, 0, 0] # TODO: make flexible depending on first vector + pi = initial_vector(gesture[0]) # in gesture m = ghmm.HMMFromMatrices(sigma, ghmm.DiscreteDistribution(sigma), A, B, pi) print(m) diff --git a/track2.py b/track2.py @@ -33,7 +33,7 @@ def execute(emission_seq, models): max_comm = None max_val = 0 for model, command in models: - #print(model.forward(emission_seq)) + print(model.forward(emission_seq)) res = model.forward(emission_seq) if res[1][-1] > max_val: @@ -88,6 +88,8 @@ while True: #print(path) else: not_changed += 1 + else: + not_changed += 1 if not_changed > 5: if len(path) >= 2: print(path)