Created
July 25, 2017 06:47
-
-
Save tsu-nera/e325c5c14499b296ce1fcdc1346a1c00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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