commit 4339216c1fa0ca4de7fecc9800a640ee0a1a7bf0
parent 366f1d93427ff56289ded727f3b5c02715a49698
Author: Stefan Koch <taikano@lavabit.com>
Date: Fri, 7 Jun 2013 21:29:43 +0200
adjusted auto generation, added gestures
Diffstat:
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/models.py b/models.py
@@ -10,12 +10,14 @@ OBSERVATIONS_COUNT = 4
gestures = [
([UP, RIGHT], ['/usr/bin/xdotool', 'getactivewindow', 'windowkill']),
([UP, LEFT], ['notify-send', '"received command"', '"Hooray!"']),
+ ([DOWN], ['amixer', 'set', 'Master', '10%-']),
+ ([UP], ['amixer', 'set', 'Master', '10%+']),
]
# TODO: Zuordnung von Indizes stimmt noch nicht
def transition_matrix(gesture):
gestes = list(set(gesture))
- A = [[0 for i in range(GESTES_COUNT)] for j in range(GESTES_COUNT)]
+ A = [[0.01 for i in range(GESTES_COUNT)] for j in range(GESTES_COUNT)]
# self transitions are high
for geste in gestes:
A[geste][geste] = 0.7
@@ -59,8 +61,18 @@ for gesture in gestures:
pi = [1, 0, 0, 0] # TODO: make flexible depending on first vector
# in gesture
m = ghmm.HMMFromMatrices(sigma, ghmm.DiscreteDistribution(sigma), A, B, pi)
+ print(m)
models.append((m, gesture[1]))
+#close = models[0][0]
+#close.baumWelch(ghmm.SequenceSet(sigma, [
+# [0, 0, 0, 0, 3, 3, 3, 3, 3],
+# [0, 0, 0, 0, 3, 3, 3, 3, 3, 1],
+# [0, 0, 0, 0, 0, 3, 3, 3, 1],
+# [0, 0, 0, 3, 3, 3],
+# [0, 0, 0, 3, 3, 3, 1]
+#]))
+
#A = [[0.7, 0.3], [0, 1]]
#B = [[0.6, 0.1, 0.2, 0.2], [.2, .2, .1, .6]]
#pi = [1, 0]
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:
@@ -42,6 +42,7 @@ def execute(emission_seq, models):
if max_val >= 0.4:
subprocess.call(max_comm)
+ print(max_comm)
cam = cv2.VideoCapture(0)
@@ -83,12 +84,13 @@ while True:
path.append(DOWN)
else:
path.append(RIGHT)
- print("Appended to")
- print(path)
+ #print("Appended to")
+ #print(path)
else:
not_changed += 1
if not_changed > 5:
if len(path) >= 2:
+ print(path)
execute(ghmm.EmissionSequence(models.sigma, path), models.models)
path = []
not_changed = 0