Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import Leap, sys
from Leap import KeyTapGesture
class SampleListener(Leap.Listener):
def on_connect(self, controller):
controller.enable_gesture(Leap.Gesture.TYPE_KEY_TAP);
def on_frame(self, controller):
# Get the most recent frame and report some basic information
frame = controller.frame()
print "Frame id: %d, timestamp: %d" % (frame.id, frame.timestamp)
hands = frame.hands
hand = hands[0] # first hand
print hand.palm_position
for gesture in frame.gestures():
if gesture.type == Leap.Gesture.TYPE_KEY_TAP:
print " Key Tap id:", gesture.id
def main():
# Create a sample listener and controller
listener = SampleListener()
controller = Leap.Controller()
# Have the sample listener receive events from the controller
controller.add_listener(listener)
# Keep this process running until Enter is pressed
print "Press Enter to quit..."
try:
sys.stdin.readline()
except KeyboardInterrupt:
pass
finally:
# Remove the sample listener when done
controller.remove_listener(listener)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment