-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhouse.py
65 lines (46 loc) · 1.65 KB
/
house.py
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
import Leap, sys, time
def house(frame):
house = [False, False]
for hand in frame.hands:
normal = hand.palm_normal
direction = hand.direction
if hand.is_left:
if (100 >= (direction.yaw * Leap.RAD_TO_DEG) >= 60) and (50 >= (normal.roll * Leap.RAD_TO_DEG) >= 20):
house[0] = True
else:
house[0] = False
elif hand.is_right:
if (-100 <= direction.yaw * Leap.RAD_TO_DEG <= -60) and (-50 <= normal.roll * Leap.RAD_TO_DEG <= -20):
house[1] = True
else:
house[1] = False
time.sleep(0.3)
if house[0] and house[1]:
print 'House'
# sys.exit(0)
class LeapMotionListener(Leap.Listener):
finger_names = ['Thumb', 'Index', 'Middle', 'Ring', 'Pinky']
bone_names = ['Metacarpol', 'Proximal', 'Intermediate', 'Distal']
state_names = ['STATE_INVALID', 'STATE_START', 'STATE_UPDATE', 'STATE_END']
def on_init(self, controller):
print 'Initialized'
def on_connect(self, controller):
print 'Connected'
def on_disconnect(self, controller):
print 'Disconnected'
def on_frame(self, controller):
frame = (controller.frame())
house(frame)
def main():
listener = LeapMotionListener()
controller = Leap.Controller()
controller.add_listener(listener)
print 'Press enter to exit'
try:
sys.stdin.readline()
except KeyboardInterrupt:
pass
finally:
controller.remove_listener(listener)
if __name__ == '__main__':
main()