Skip to content

Instantly share code, notes, and snippets.

@tsu-nera
Created July 25, 2017 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsu-nera/e325c5c14499b296ce1fcdc1346a1c00 to your computer and use it in GitHub Desktop.
Save tsu-nera/e325c5c14499b296ce1fcdc1346a1c00 to your computer and use it in GitHub Desktop.
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