import Leap, sys, thread, time
from Leap import CircleGesture, KeyTapGesture, ScreenTapGesture, SwipeGesture
from flask import Flask
class LeapMotionListener(Leap.Listener):
finger_names = ['Thumb', 'Index', 'Middle', 'Ring', 'Pinky']
bone_names = ['Metacarpal','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 "Motion Sensor Connected!"
controller.enable_gesture(Leap.Gesture.TYPE_CIRCLE);
controller.enable_gesture(Leap.Gesture.TYPE_KEY_TAP);
controller.enable_gesture(Leap.Gesture.TYPE_SCREEN_TAP);
controller.enable_gesture(Leap.Gesture.TYPE_SWIPE);
def on_disconnect(self, controller):
print "Motion Sensor Disconnected"
def on_exit(self, controller):
print "Existed"
def on_frame(self, controller):
frame = controller.frame()
#print " Number of Hands: " + str(len(frame.hands))
hand = str(len(frame.hands))
print hand
return hand
def main():
listener = LeapMotionListener()
controller = Leap.Controller()
controller.add_listener(listener)
print "Press enter to quit"
try:
sys.stdin.readline()
except KeyboardInterrupt:
pass
finally:
controller.remove_listener(listener)
if __name__ == "__main__":
main()
The output is: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 111111 0 0 0 0 0 0 0 0 0 0 0 goes on until I terminate the program.
I want this output to be sent to webpage using flask. how can i do it?
NOTE: The above is a leapmotion hand detection program. the above program runs only with python 32bit and having leapmotion sdk