-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandmode.py
More file actions
100 lines (92 loc) · 1.91 KB
/
handmode.py
File metadata and controls
100 lines (92 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"""
This module implements FSM of Hand mode
"""
# imports
import pdb
import numpy as np
import cv2
def hand_mode(est_gesture,current_state,count_2,count_1,count_n1):
"""
This function implements FSM of hand mode
FSM has four states:
1 - Active : when recording
2 - Start : start of recording
3 - Deactive : when hand is down or clenched
4 - Stop : stop of recording
"""
start2active=8/2
#start2deactive=
#stop2active=
stop2deactive=10/2
active2stop=2/1
active2deactive=40/2
deactive2start=2/1
deactive2active=40/2
nextstate = current_state
if (est_gesture== -1) :
count_n1 = count_n1 + 1
elif (est_gesture== 1) :
count_1 = count_1 + 1
elif (est_gesture== 2) :
count_2 = count_2 + 1
if (current_state == "Deactive") :
if count_1 >= deactive2start :
nextstate = "Start"
count_2=0
count_1=0
count_n1=0
elif count_2 >= deactive2active :
nextstate = "Active"
count_2=0
count_1=0
count_n1=0
if est_gesture == -1 :
count_2=0
count_1=0
count_n1=0
elif (current_state == "Start") :
if count_2 >= start2active :
nextstate = "Active"
count_2=0
count_1=0
count_n1=0
#elif count_n1 >= start2deactive :
# nextstate = "Deactive"
# count_2=0
# count_1=0
# count_n1=0
if est_gesture == 1 :
count_2=0
count_1=0
count_n1=0
elif (current_state == "Stop") :
if count_n1 >= stop2deactive :
nextstate = "Deactive"
count_2=0
count_1=0
count_n1=0
#elif count_2 >= stop2active :
# nextstate = "Active"
# count_2=0
# count_1=0
# count_n1=0
if est_gesture == 1 :
count_2=0
count_1=0
count_n1=0
elif (current_state == "Active") :
if count_1 >= active2stop :
nextstate = "Stop"
count_2=0
count_1=0
count_n1=0
elif count_n1 >= active2deactive :
nextstate = "Deactive"
count_2=0
count_1=0
count_n1=0
if est_gesture == 2 :
count_2=0
count_1=0
count_n1=0
return nextstate,count_2,count_1,count_n1