gestures

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

commit 9429352d17e2ddc556fa68a9c0cc1680d060e1cb
parent 8ca7ada2aaab6313eaefaac33a362d8692e44f87
Author: Stefan Koch <taikano@lavabit.com>
Date:   Tue, 18 Jun 2013 12:02:41 +0200

added models folder with readme file, and add extension to training files

Diffstat:
M.gitignore | 2+-
Mmodels.py | 5+++--
Amodels/README | 1+
Mtrack.py | 4++--
4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,2 +1,2 @@ *.pyc -models +models/*.train diff --git a/models.py b/models.py @@ -18,6 +18,7 @@ gestures = [ ([UP, LEFT], ['notify-send', '"received command"', '"Hooray!"']), ([DOWN], ['amixer', 'set', 'Master', '10%-']), ([UP], ['amixer', 'set', 'Master', '10%+']), + ([UP, DOWN, UP], ['mplayer']), ] training_data = [[] for gesture in gestures] @@ -74,8 +75,8 @@ for gesture in gestures: m = ghmm.HMMFromMatrices(sigma, ghmm.DiscreteDistribution(sigma), A, B, pi) - if os.path.isfile('/'.join(('models', str(i)))): - with open('/'.join(('models', str(i)))) as f: + if os.path.isfile(''.join(('models/', str(i), '.train'))): + with open(''.join(('models/', str(i), '.train'))) as f: training_data[i] = simplejson.load(f) m.baumWelch(ghmm.SequenceSet(sigma, training_data[i])) print(m) diff --git a/models/README b/models/README @@ -0,0 +1 @@ +This folder contains training data for the gestures. diff --git a/track.py b/track.py @@ -133,7 +133,7 @@ while True: train_mode = False print("Leaving training mode") - with open("/".join(('models', str(train_target))), 'w') as f: + with open("".join(('models/', str(train_target), '.train')), 'w') as f: simplejson.dump(models.training_data[train_target], f) path = [] @@ -141,7 +141,7 @@ while True: cv2.imshow(winName, img) - key = cv2.waitKey(50) + key = cv2.waitKey(1) if key == 27: cv2.destroyWindow(winName) break