diff --git a/PoC/README b/PoC/README index 4412749..43cdb13 100644 --- a/PoC/README +++ b/PoC/README @@ -10,6 +10,8 @@ PoC/ = This plays pre-defined patterns -> life = Game of Life +-> leap += Leap motion controller demo -> cheap_random = dirty hack to show random windows -> 7seg @@ -25,6 +27,7 @@ PoC/ -> testcolors = Test the 16x32 RGB Panel +Leap motion Python issues: under OS-X make sure you use the stock Python interpreter (/usr/bin/python) The shift Array code is from this Tutorial page: diff --git a/PoC/leap/HandsPoC.py b/PoC/leap/HandsPoC.py new file mode 100755 index 0000000..be7680c --- /dev/null +++ b/PoC/leap/HandsPoC.py @@ -0,0 +1,197 @@ +#!/usr/bin/python +################################################################################ +# Copyright (C) 2012-2013 Leap Motion, Inc. All rights reserved. # +# Leap Motion proprietary and confidential. Not for distribution. # +# Use subject to the terms of the Leap Motion SDK Agreement available at # +# https://developer.leapmotion.com/sdk_agreement, or another agreement # +# between Leap Motion and you, your company or other organization. # +################################################################################ + +import Leap, sys +import serial, time, os +from Leap import CircleGesture, KeyTapGesture, ScreenTapGesture, SwipeGesture + +tty_USB = "/dev/tty.usbserial-A7005FGN" + +ser = serial.Serial(port = tty_USB, baudrate=9600) +ser.close() +ser.open() +time.sleep(1) + +class SampleListener(Leap.Listener): + def on_init(self, controller): + print "Initialized" + + def on_connect(self, controller): + print "Connected" + + # Enable gestures + 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): + # Note: not dispatched when running in a debugger. + print "Disconnected" + + def on_exit(self, controller): + print "Exited" + + def on_frame(self, controller): + # Get the most recent frame and report some basic information + frame = controller.frame() + + ##print "Frame id: %d, timestamp: %d, hands: %d, fingers: %d, tools: %d, gestures: %d" % ( + ## frame.id, frame.timestamp, len(frame.hands), len(frame.fingers), len(frame.tools), len(frame.gestures())) + + if not frame.hands.empty: + # Get the first hand + hand = frame.hands[0] + + # Check if the hand has any fingers + fingers = hand.fingers + + # Check if there is a fist + if hand and fingers.empty: + print "We have a fist, so let's make the ball vanish" + if ser.isOpen(): + ser.write(str(0)) + time.sleep(0.3) +# if len(frame.hands) == 1 and len(fingers) == 5: +# print "We have a one full hand, so let's make the ball appear" +# if ser.isOpen(): +# ser.write(str(1)) +# time.sleep(0.3) + if len(frame.hands) == 2 and len(fingers) == 5: + print "We have a two full hands, so let's make the balls appear" + if ser.isOpen(): + ser.write(str(2)) + time.sleep(0.3) + if len(frame.hands) == 2 and len(fingers) == 2: + print "Bye Bye" + ##if ser.isOpen(): + ## ser.write(str(9)) + time.sleep(0.3) + + if not fingers.empty: + # Calculate the hand's average finger tip position + avg_pos = Leap.Vector() + for finger in fingers: + avg_pos += finger.tip_position + avg_pos /= len(fingers) + ##print "Hand has %d fingers, average finger tip position: %s" % ( + ## len(fingers), avg_pos) + + # Get the hand's sphere radius and palm position + ##print "Hand sphere radius: %f mm, palm position: %s" % ( + ## hand.sphere_radius, hand.palm_position[0]) + #print "Number of Hands: %s - Number of fingers: %s - Palm position: %s" % ( len(frame.hands), len(fingers), hand.palm_position[0]) + if len(frame.hands) == 1 and len(fingers) == 5 and -170 < hand.palm_position[0] < -85: + print "w5" + if ser.isOpen(): + ser.write(str(4)) + time.sleep(0.3) + if len(frame.hands) == 1 and len(fingers) == 5 and -84 < hand.palm_position[0] < 0: + print "w10" + if ser.isOpen(): + ser.write(str(5)) + time.sleep(0.3) + if len(frame.hands) == 1 and len(fingers) == 5 and 1 < hand.palm_position[0] < 85: + print "w15" + if ser.isOpen(): + ser.write(str(6)) + time.sleep(0.3) + if len(frame.hands) == 1 and len(fingers) == 5 and 86 < hand.palm_position[0] < 170: + print "w20" + if ser.isOpen(): + ser.write(str(7)) + time.sleep(0.3) + + + # Get the hand's normal vector and direction + normal = hand.palm_normal + direction = hand.direction + + # Calculate the hand's pitch, roll, and yaw angles + ##print "Hand pitch: %f degrees, roll: %f degrees, yaw: %f degrees" % ( + ## direction.pitch * Leap.RAD_TO_DEG, + ## normal.roll * Leap.RAD_TO_DEG, + ## direction.yaw * Leap.RAD_TO_DEG) + + # Gestures + for gesture in frame.gestures(): + if gesture.type == Leap.Gesture.TYPE_CIRCLE: + circle = CircleGesture(gesture) + + # Determine clock direction using the angle between the pointable and the circle normal + if circle.pointable.direction.angle_to(circle.normal) <= Leap.PI/4: + clockwiseness = "clockwise" + else: + clockwiseness = "counterclockwise" + + # Calculate the angle swept since the last frame + swept_angle = 0 + if circle.state != Leap.Gesture.STATE_START: + previous_update = CircleGesture(controller.frame(1).gesture(circle.id)) + swept_angle = (circle.progress - previous_update.progress) * 2 * Leap.PI + + ##print "Circle id: %d, %s, progress: %f, radius: %f, angle: %f degrees, %s" % ( + ## gesture.id, self.state_string(gesture.state), + ## circle.progress, circle.radius, swept_angle * Leap.RAD_TO_DEG, clockwiseness) + + if gesture.type == Leap.Gesture.TYPE_SWIPE: + swipe = SwipeGesture(gesture) + ##print "Swipe id: %d, state: %s, position: %s, direction: %s, speed: %f" % ( + ## gesture.id, self.state_string(gesture.state), + ## swipe.position, swipe.direction, swipe.speed) + + if gesture.type == Leap.Gesture.TYPE_KEY_TAP: + keytap = KeyTapGesture(gesture) + print "Key Tap id: %d, %s, position: %s, direction: %s" % ( + gesture.id, self.state_string(gesture.state), + keytap.position, keytap.direction ) + if ser.isOpen(): + ser.write(str(3)) + time.sleep(0.3) + + if gesture.type == Leap.Gesture.TYPE_SCREEN_TAP: + screentap = ScreenTapGesture(gesture) + ##print "Screen Tap id: %d, %s, position: %s, direction: %s" % ( + ## gesture.id, self.state_string(gesture.state), + ## screentap.position, screentap.direction ) + + #if not (frame.hands.empty and frame.gestures().empty): + # print "" + + def state_string(self, state): + if state == Leap.Gesture.STATE_START: + return "STATE_START" + + if state == Leap.Gesture.STATE_UPDATE: + return "STATE_UPDATE" + + if state == Leap.Gesture.STATE_STOP: + return "STATE_STOP" + + if state == Leap.Gesture.STATE_INVALID: + return "STATE_INVALID" + +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..." + sys.stdin.readline() + + # Remove the sample listener when done + controller.remove_listener(listener) + + +if __name__ == "__main__": + main() diff --git a/PoC/leap/Leap.py b/PoC/leap/Leap.py new file mode 100644 index 0000000..d61ba00 --- /dev/null +++ b/PoC/leap/Leap.py @@ -0,0 +1,1082 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 2.0.9 +# +# Do not make changes to this file unless you know what you are doing--modify +# the SWIG interface file instead. + + + +from sys import version_info +if version_info >= (2,6,0): + def swig_import_helper(): + from os.path import dirname + import imp + fp = None + try: + fp, pathname, description = imp.find_module('LeapPython', [dirname(__file__)]) + except ImportError: + import LeapPython + return LeapPython + if fp is not None: + try: + _mod = imp.load_module('LeapPython', fp, pathname, description) + finally: + fp.close() + return _mod + LeapPython = swig_import_helper() + del swig_import_helper +else: + import LeapPython +del version_info +try: + _swig_property = property +except NameError: + pass # Python < 2.2 doesn't have 'property'. +def _swig_setattr_nondynamic(self,class_type,name,value,static=1): + if (name == "thisown"): return self.this.own(value) + if (name == "this"): + if type(value).__name__ == 'SwigPyObject': + self.__dict__[name] = value + return + method = class_type.__swig_setmethods__.get(name,None) + if method: return method(self,value) + if (not static): + self.__dict__[name] = value + else: + raise AttributeError("You cannot add attributes to %s" % self) + +def _swig_setattr(self,class_type,name,value): + return _swig_setattr_nondynamic(self,class_type,name,value,0) + +def _swig_getattr(self,class_type,name): + if (name == "thisown"): return self.this.own() + method = class_type.__swig_getmethods__.get(name,None) + if method: return method(self) + raise AttributeError(name) + +def _swig_repr(self): + try: strthis = "proxy of " + self.this.__repr__() + except: strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + +try: + _object = object + _newclass = 1 +except AttributeError: + class _object : pass + _newclass = 0 + + +try: + import weakref + weakref_proxy = weakref.proxy +except: + weakref_proxy = lambda x: x + + +class SwigPyIterator(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, SwigPyIterator, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, SwigPyIterator, name) + def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract") + __repr__ = _swig_repr + __swig_destroy__ = LeapPython.delete_SwigPyIterator + __del__ = lambda self : None; + def value(self): return LeapPython.SwigPyIterator_value(self) + def incr(self, n=1): return LeapPython.SwigPyIterator_incr(self, n) + def decr(self, n=1): return LeapPython.SwigPyIterator_decr(self, n) + def distance(self, *args): return LeapPython.SwigPyIterator_distance(self, *args) + def equal(self, *args): return LeapPython.SwigPyIterator_equal(self, *args) + def copy(self): return LeapPython.SwigPyIterator_copy(self) + def next(self): return LeapPython.SwigPyIterator_next(self) + def __next__(self): return LeapPython.SwigPyIterator___next__(self) + def previous(self): return LeapPython.SwigPyIterator_previous(self) + def advance(self, *args): return LeapPython.SwigPyIterator_advance(self, *args) + def __eq__(self, *args): return LeapPython.SwigPyIterator___eq__(self, *args) + def __ne__(self, *args): return LeapPython.SwigPyIterator___ne__(self, *args) + def __iadd__(self, *args): return LeapPython.SwigPyIterator___iadd__(self, *args) + def __isub__(self, *args): return LeapPython.SwigPyIterator___isub__(self, *args) + def __add__(self, *args): return LeapPython.SwigPyIterator___add__(self, *args) + def __sub__(self, *args): return LeapPython.SwigPyIterator___sub__(self, *args) + def __iter__(self): return self +SwigPyIterator_swigregister = LeapPython.SwigPyIterator_swigregister +SwigPyIterator_swigregister(SwigPyIterator) + +class Vector(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, Vector, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, Vector, name) + __repr__ = _swig_repr + def __init__(self, *args): + this = LeapPython.new_Vector(*args) + try: self.this.append(this) + except: self.this = this + def distance_to(self, *args): return LeapPython.Vector_distance_to(self, *args) + def angle_to(self, *args): return LeapPython.Vector_angle_to(self, *args) + def dot(self, *args): return LeapPython.Vector_dot(self, *args) + def cross(self, *args): return LeapPython.Vector_cross(self, *args) + def __neg__(self): return LeapPython.Vector___neg__(self) + def __add__(self, *args): return LeapPython.Vector___add__(self, *args) + def __sub__(self, *args): return LeapPython.Vector___sub__(self, *args) + def __mul__(self, *args): return LeapPython.Vector___mul__(self, *args) + def __div__(self, *args): return LeapPython.Vector___div__(self, *args) + def __iadd__(self, *args): return LeapPython.Vector___iadd__(self, *args) + def __isub__(self, *args): return LeapPython.Vector___isub__(self, *args) + def __imul__(self, *args): return LeapPython.Vector___imul__(self, *args) + def __idiv__(self, *args): return LeapPython.Vector___idiv__(self, *args) + def __str__(self): return LeapPython.Vector___str__(self) + def __eq__(self, *args): return LeapPython.Vector___eq__(self, *args) + def __ne__(self, *args): return LeapPython.Vector___ne__(self, *args) + def is_valid(self): return LeapPython.Vector_is_valid(self) + def __getitem__(self, *args): return LeapPython.Vector___getitem__(self, *args) + __swig_setmethods__["x"] = LeapPython.Vector_x_set + __swig_getmethods__["x"] = LeapPython.Vector_x_get + if _newclass:x = _swig_property(LeapPython.Vector_x_get, LeapPython.Vector_x_set) + __swig_setmethods__["y"] = LeapPython.Vector_y_set + __swig_getmethods__["y"] = LeapPython.Vector_y_get + if _newclass:y = _swig_property(LeapPython.Vector_y_get, LeapPython.Vector_y_set) + __swig_setmethods__["z"] = LeapPython.Vector_z_set + __swig_getmethods__["z"] = LeapPython.Vector_z_get + if _newclass:z = _swig_property(LeapPython.Vector_z_get, LeapPython.Vector_z_set) + __swig_getmethods__["magnitude"] = LeapPython.Vector_magnitude_get + if _newclass:magnitude = _swig_property(LeapPython.Vector_magnitude_get) + __swig_getmethods__["magnitude_squared"] = LeapPython.Vector_magnitude_squared_get + if _newclass:magnitude_squared = _swig_property(LeapPython.Vector_magnitude_squared_get) + __swig_getmethods__["pitch"] = LeapPython.Vector_pitch_get + if _newclass:pitch = _swig_property(LeapPython.Vector_pitch_get) + __swig_getmethods__["roll"] = LeapPython.Vector_roll_get + if _newclass:roll = _swig_property(LeapPython.Vector_roll_get) + __swig_getmethods__["yaw"] = LeapPython.Vector_yaw_get + if _newclass:yaw = _swig_property(LeapPython.Vector_yaw_get) + __swig_getmethods__["normalized"] = LeapPython.Vector_normalized_get + if _newclass:normalized = _swig_property(LeapPython.Vector_normalized_get) + def to_float_array(self): return [self.x, self.y, self.z] + def to_tuple(self): return (self.x, self.y, self.z) + + __swig_destroy__ = LeapPython.delete_Vector + __del__ = lambda self : None; +Vector_swigregister = LeapPython.Vector_swigregister +Vector_swigregister(Vector) +cvar = LeapPython.cvar +PI = cvar.PI +DEG_TO_RAD = cvar.DEG_TO_RAD +RAD_TO_DEG = cvar.RAD_TO_DEG +Vector.zero = LeapPython.cvar.Vector_zero +Vector.x_axis = LeapPython.cvar.Vector_x_axis +Vector.y_axis = LeapPython.cvar.Vector_y_axis +Vector.z_axis = LeapPython.cvar.Vector_z_axis +Vector.forward = LeapPython.cvar.Vector_forward +Vector.backward = LeapPython.cvar.Vector_backward +Vector.left = LeapPython.cvar.Vector_left +Vector.right = LeapPython.cvar.Vector_right +Vector.up = LeapPython.cvar.Vector_up +Vector.down = LeapPython.cvar.Vector_down + +class Matrix(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, Matrix, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, Matrix, name) + __repr__ = _swig_repr + def __init__(self, *args): + this = LeapPython.new_Matrix(*args) + try: self.this.append(this) + except: self.this = this + def set_rotation(self, *args): return LeapPython.Matrix_set_rotation(self, *args) + def transform_point(self, *args): return LeapPython.Matrix_transform_point(self, *args) + def transform_direction(self, *args): return LeapPython.Matrix_transform_direction(self, *args) + def rigid_inverse(self): return LeapPython.Matrix_rigid_inverse(self) + def __mul__(self, *args): return LeapPython.Matrix___mul__(self, *args) + def __imul__(self, *args): return LeapPython.Matrix___imul__(self, *args) + def __eq__(self, *args): return LeapPython.Matrix___eq__(self, *args) + def __ne__(self, *args): return LeapPython.Matrix___ne__(self, *args) + def __str__(self): return LeapPython.Matrix___str__(self) + __swig_setmethods__["x_basis"] = LeapPython.Matrix_x_basis_set + __swig_getmethods__["x_basis"] = LeapPython.Matrix_x_basis_get + if _newclass:x_basis = _swig_property(LeapPython.Matrix_x_basis_get, LeapPython.Matrix_x_basis_set) + __swig_setmethods__["y_basis"] = LeapPython.Matrix_y_basis_set + __swig_getmethods__["y_basis"] = LeapPython.Matrix_y_basis_get + if _newclass:y_basis = _swig_property(LeapPython.Matrix_y_basis_get, LeapPython.Matrix_y_basis_set) + __swig_setmethods__["z_basis"] = LeapPython.Matrix_z_basis_set + __swig_getmethods__["z_basis"] = LeapPython.Matrix_z_basis_get + if _newclass:z_basis = _swig_property(LeapPython.Matrix_z_basis_get, LeapPython.Matrix_z_basis_set) + __swig_setmethods__["origin"] = LeapPython.Matrix_origin_set + __swig_getmethods__["origin"] = LeapPython.Matrix_origin_get + if _newclass:origin = _swig_property(LeapPython.Matrix_origin_get, LeapPython.Matrix_origin_set) + def to_array_3x3(self, output = None): + if output is None: + output = [0]*9 + output[0], output[1], output[2] = self.x_basis.x, self.x_basis.y, self.x_basis.z + output[3], output[4], output[5] = self.y_basis.x, self.y_basis.y, self.y_basis.z + output[6], output[7], output[8] = self.z_basis.x, self.z_basis.y, self.z_basis.z + return output + def to_array_4x4(self, output = None): + if output is None: + output = [0]*16 + output[0], output[1], output[2], output[3] = self.x_basis.x, self.x_basis.y, self.x_basis.z, 0.0 + output[4], output[5], output[6], output[7] = self.y_basis.x, self.y_basis.y, self.y_basis.z, 0.0 + output[8], output[9], output[10], output[11] = self.z_basis.x, self.z_basis.y, self.z_basis.z, 0.0 + output[12], output[13], output[14], output[15] = self.origin.x, self.origin.y, self.origin.z, 1.0 + return output + + __swig_destroy__ = LeapPython.delete_Matrix + __del__ = lambda self : None; +Matrix_swigregister = LeapPython.Matrix_swigregister +Matrix_swigregister(Matrix) +Matrix.identity = LeapPython.cvar.Matrix_identity + +class Interface(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, Interface, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, Interface, name) + def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined") + __repr__ = _swig_repr +Interface_swigregister = LeapPython.Interface_swigregister +Interface_swigregister(Interface) + +class Pointable(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, Pointable, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, Pointable, name) + __repr__ = _swig_repr + ZONE_NONE = LeapPython.Pointable_ZONE_NONE + ZONE_HOVERING = LeapPython.Pointable_ZONE_HOVERING + ZONE_TOUCHING = LeapPython.Pointable_ZONE_TOUCHING + def __init__(self): + this = LeapPython.new_Pointable() + try: self.this.append(this) + except: self.this = this + def __eq__(self, *args): return LeapPython.Pointable___eq__(self, *args) + def __ne__(self, *args): return LeapPython.Pointable___ne__(self, *args) + def __str__(self): return LeapPython.Pointable___str__(self) + __swig_getmethods__["id"] = LeapPython.Pointable_id_get + if _newclass:id = _swig_property(LeapPython.Pointable_id_get) + __swig_getmethods__["hand"] = LeapPython.Pointable_hand_get + if _newclass:hand = _swig_property(LeapPython.Pointable_hand_get) + __swig_getmethods__["tip_position"] = LeapPython.Pointable_tip_position_get + if _newclass:tip_position = _swig_property(LeapPython.Pointable_tip_position_get) + __swig_getmethods__["tip_velocity"] = LeapPython.Pointable_tip_velocity_get + if _newclass:tip_velocity = _swig_property(LeapPython.Pointable_tip_velocity_get) + __swig_getmethods__["direction"] = LeapPython.Pointable_direction_get + if _newclass:direction = _swig_property(LeapPython.Pointable_direction_get) + __swig_getmethods__["width"] = LeapPython.Pointable_width_get + if _newclass:width = _swig_property(LeapPython.Pointable_width_get) + __swig_getmethods__["length"] = LeapPython.Pointable_length_get + if _newclass:length = _swig_property(LeapPython.Pointable_length_get) + __swig_getmethods__["is_tool"] = LeapPython.Pointable_is_tool_get + if _newclass:is_tool = _swig_property(LeapPython.Pointable_is_tool_get) + __swig_getmethods__["is_finger"] = LeapPython.Pointable_is_finger_get + if _newclass:is_finger = _swig_property(LeapPython.Pointable_is_finger_get) + __swig_getmethods__["is_valid"] = LeapPython.Pointable_is_valid_get + if _newclass:is_valid = _swig_property(LeapPython.Pointable_is_valid_get) + __swig_getmethods__["touch_zone"] = LeapPython.Pointable_touch_zone_get + if _newclass:touch_zone = _swig_property(LeapPython.Pointable_touch_zone_get) + __swig_getmethods__["touch_distance"] = LeapPython.Pointable_touch_distance_get + if _newclass:touch_distance = _swig_property(LeapPython.Pointable_touch_distance_get) + __swig_getmethods__["stabilized_tip_position"] = LeapPython.Pointable_stabilized_tip_position_get + if _newclass:stabilized_tip_position = _swig_property(LeapPython.Pointable_stabilized_tip_position_get) + __swig_getmethods__["time_visible"] = LeapPython.Pointable_time_visible_get + if _newclass:time_visible = _swig_property(LeapPython.Pointable_time_visible_get) + __swig_getmethods__["frame"] = LeapPython.Pointable_frame_get + if _newclass:frame = _swig_property(LeapPython.Pointable_frame_get) + __swig_destroy__ = LeapPython.delete_Pointable + __del__ = lambda self : None; +Pointable_swigregister = LeapPython.Pointable_swigregister +Pointable_swigregister(Pointable) +Pointable.invalid = LeapPython.cvar.Pointable_invalid + +class Finger(Pointable): + __swig_setmethods__ = {} + for _s in [Pointable]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, Finger, name, value) + __swig_getmethods__ = {} + for _s in [Pointable]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, Finger, name) + __repr__ = _swig_repr + def __init__(self, *args): + this = LeapPython.new_Finger(*args) + try: self.this.append(this) + except: self.this = this + def __str__(self): return LeapPython.Finger___str__(self) + __swig_destroy__ = LeapPython.delete_Finger + __del__ = lambda self : None; +Finger_swigregister = LeapPython.Finger_swigregister +Finger_swigregister(Finger) +Finger.invalid = LeapPython.cvar.Finger_invalid + +class Tool(Pointable): + __swig_setmethods__ = {} + for _s in [Pointable]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, Tool, name, value) + __swig_getmethods__ = {} + for _s in [Pointable]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, Tool, name) + __repr__ = _swig_repr + def __init__(self, *args): + this = LeapPython.new_Tool(*args) + try: self.this.append(this) + except: self.this = this + def __str__(self): return LeapPython.Tool___str__(self) + __swig_destroy__ = LeapPython.delete_Tool + __del__ = lambda self : None; +Tool_swigregister = LeapPython.Tool_swigregister +Tool_swigregister(Tool) +Tool.invalid = LeapPython.cvar.Tool_invalid + +class Hand(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, Hand, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, Hand, name) + __repr__ = _swig_repr + def __init__(self): + this = LeapPython.new_Hand() + try: self.this.append(this) + except: self.this = this + def pointable(self, *args): return LeapPython.Hand_pointable(self, *args) + def finger(self, *args): return LeapPython.Hand_finger(self, *args) + def tool(self, *args): return LeapPython.Hand_tool(self, *args) + def translation(self, *args): return LeapPython.Hand_translation(self, *args) + def translation_probability(self, *args): return LeapPython.Hand_translation_probability(self, *args) + def rotation_axis(self, *args): return LeapPython.Hand_rotation_axis(self, *args) + def rotation_angle(self, *args): return LeapPython.Hand_rotation_angle(self, *args) + def rotation_matrix(self, *args): return LeapPython.Hand_rotation_matrix(self, *args) + def rotation_probability(self, *args): return LeapPython.Hand_rotation_probability(self, *args) + def scale_factor(self, *args): return LeapPython.Hand_scale_factor(self, *args) + def scale_probability(self, *args): return LeapPython.Hand_scale_probability(self, *args) + def __eq__(self, *args): return LeapPython.Hand___eq__(self, *args) + def __ne__(self, *args): return LeapPython.Hand___ne__(self, *args) + def __str__(self): return LeapPython.Hand___str__(self) + __swig_getmethods__["id"] = LeapPython.Hand_id_get + if _newclass:id = _swig_property(LeapPython.Hand_id_get) + __swig_getmethods__["pointables"] = LeapPython.Hand_pointables_get + if _newclass:pointables = _swig_property(LeapPython.Hand_pointables_get) + __swig_getmethods__["fingers"] = LeapPython.Hand_fingers_get + if _newclass:fingers = _swig_property(LeapPython.Hand_fingers_get) + __swig_getmethods__["tools"] = LeapPython.Hand_tools_get + if _newclass:tools = _swig_property(LeapPython.Hand_tools_get) + __swig_getmethods__["palm_position"] = LeapPython.Hand_palm_position_get + if _newclass:palm_position = _swig_property(LeapPython.Hand_palm_position_get) + __swig_getmethods__["palm_velocity"] = LeapPython.Hand_palm_velocity_get + if _newclass:palm_velocity = _swig_property(LeapPython.Hand_palm_velocity_get) + __swig_getmethods__["palm_normal"] = LeapPython.Hand_palm_normal_get + if _newclass:palm_normal = _swig_property(LeapPython.Hand_palm_normal_get) + __swig_getmethods__["direction"] = LeapPython.Hand_direction_get + if _newclass:direction = _swig_property(LeapPython.Hand_direction_get) + __swig_getmethods__["is_valid"] = LeapPython.Hand_is_valid_get + if _newclass:is_valid = _swig_property(LeapPython.Hand_is_valid_get) + __swig_getmethods__["sphere_center"] = LeapPython.Hand_sphere_center_get + if _newclass:sphere_center = _swig_property(LeapPython.Hand_sphere_center_get) + __swig_getmethods__["sphere_radius"] = LeapPython.Hand_sphere_radius_get + if _newclass:sphere_radius = _swig_property(LeapPython.Hand_sphere_radius_get) + __swig_getmethods__["stabilized_palm_position"] = LeapPython.Hand_stabilized_palm_position_get + if _newclass:stabilized_palm_position = _swig_property(LeapPython.Hand_stabilized_palm_position_get) + __swig_getmethods__["time_visible"] = LeapPython.Hand_time_visible_get + if _newclass:time_visible = _swig_property(LeapPython.Hand_time_visible_get) + __swig_getmethods__["frame"] = LeapPython.Hand_frame_get + if _newclass:frame = _swig_property(LeapPython.Hand_frame_get) + __swig_destroy__ = LeapPython.delete_Hand + __del__ = lambda self : None; +Hand_swigregister = LeapPython.Hand_swigregister +Hand_swigregister(Hand) +Hand.invalid = LeapPython.cvar.Hand_invalid + +class Gesture(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, Gesture, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, Gesture, name) + __repr__ = _swig_repr + TYPE_INVALID = LeapPython.Gesture_TYPE_INVALID + TYPE_SWIPE = LeapPython.Gesture_TYPE_SWIPE + TYPE_CIRCLE = LeapPython.Gesture_TYPE_CIRCLE + TYPE_SCREEN_TAP = LeapPython.Gesture_TYPE_SCREEN_TAP + TYPE_KEY_TAP = LeapPython.Gesture_TYPE_KEY_TAP + STATE_INVALID = LeapPython.Gesture_STATE_INVALID + STATE_START = LeapPython.Gesture_STATE_START + STATE_UPDATE = LeapPython.Gesture_STATE_UPDATE + STATE_STOP = LeapPython.Gesture_STATE_STOP + def __init__(self, *args): + this = LeapPython.new_Gesture(*args) + try: self.this.append(this) + except: self.this = this + def __eq__(self, *args): return LeapPython.Gesture___eq__(self, *args) + def __ne__(self, *args): return LeapPython.Gesture___ne__(self, *args) + def __str__(self): return LeapPython.Gesture___str__(self) + __swig_getmethods__["type"] = LeapPython.Gesture_type_get + if _newclass:type = _swig_property(LeapPython.Gesture_type_get) + __swig_getmethods__["state"] = LeapPython.Gesture_state_get + if _newclass:state = _swig_property(LeapPython.Gesture_state_get) + __swig_getmethods__["id"] = LeapPython.Gesture_id_get + if _newclass:id = _swig_property(LeapPython.Gesture_id_get) + __swig_getmethods__["duration"] = LeapPython.Gesture_duration_get + if _newclass:duration = _swig_property(LeapPython.Gesture_duration_get) + __swig_getmethods__["duration_seconds"] = LeapPython.Gesture_duration_seconds_get + if _newclass:duration_seconds = _swig_property(LeapPython.Gesture_duration_seconds_get) + __swig_getmethods__["frame"] = LeapPython.Gesture_frame_get + if _newclass:frame = _swig_property(LeapPython.Gesture_frame_get) + __swig_getmethods__["hands"] = LeapPython.Gesture_hands_get + if _newclass:hands = _swig_property(LeapPython.Gesture_hands_get) + __swig_getmethods__["pointables"] = LeapPython.Gesture_pointables_get + if _newclass:pointables = _swig_property(LeapPython.Gesture_pointables_get) + __swig_getmethods__["is_valid"] = LeapPython.Gesture_is_valid_get + if _newclass:is_valid = _swig_property(LeapPython.Gesture_is_valid_get) + __swig_destroy__ = LeapPython.delete_Gesture + __del__ = lambda self : None; +Gesture_swigregister = LeapPython.Gesture_swigregister +Gesture_swigregister(Gesture) +Gesture.invalid = LeapPython.cvar.Gesture_invalid + +class SwipeGesture(Gesture): + __swig_setmethods__ = {} + for _s in [Gesture]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, SwipeGesture, name, value) + __swig_getmethods__ = {} + for _s in [Gesture]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, SwipeGesture, name) + __repr__ = _swig_repr + __swig_getmethods__["class_type"] = lambda x: LeapPython.SwipeGesture_class_type + if _newclass:class_type = staticmethod(LeapPython.SwipeGesture_class_type) + def __init__(self, *args): + this = LeapPython.new_SwipeGesture(*args) + try: self.this.append(this) + except: self.this = this + __swig_getmethods__["start_position"] = LeapPython.SwipeGesture_start_position_get + if _newclass:start_position = _swig_property(LeapPython.SwipeGesture_start_position_get) + __swig_getmethods__["position"] = LeapPython.SwipeGesture_position_get + if _newclass:position = _swig_property(LeapPython.SwipeGesture_position_get) + __swig_getmethods__["direction"] = LeapPython.SwipeGesture_direction_get + if _newclass:direction = _swig_property(LeapPython.SwipeGesture_direction_get) + __swig_getmethods__["speed"] = LeapPython.SwipeGesture_speed_get + if _newclass:speed = _swig_property(LeapPython.SwipeGesture_speed_get) + __swig_getmethods__["pointable"] = LeapPython.SwipeGesture_pointable_get + if _newclass:pointable = _swig_property(LeapPython.SwipeGesture_pointable_get) + __swig_destroy__ = LeapPython.delete_SwipeGesture + __del__ = lambda self : None; +SwipeGesture_swigregister = LeapPython.SwipeGesture_swigregister +SwipeGesture_swigregister(SwipeGesture) + +def SwipeGesture_class_type(): + return LeapPython.SwipeGesture_class_type() +SwipeGesture_class_type = LeapPython.SwipeGesture_class_type + +class CircleGesture(Gesture): + __swig_setmethods__ = {} + for _s in [Gesture]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, CircleGesture, name, value) + __swig_getmethods__ = {} + for _s in [Gesture]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, CircleGesture, name) + __repr__ = _swig_repr + __swig_getmethods__["class_type"] = lambda x: LeapPython.CircleGesture_class_type + if _newclass:class_type = staticmethod(LeapPython.CircleGesture_class_type) + def __init__(self, *args): + this = LeapPython.new_CircleGesture(*args) + try: self.this.append(this) + except: self.this = this + __swig_getmethods__["center"] = LeapPython.CircleGesture_center_get + if _newclass:center = _swig_property(LeapPython.CircleGesture_center_get) + __swig_getmethods__["normal"] = LeapPython.CircleGesture_normal_get + if _newclass:normal = _swig_property(LeapPython.CircleGesture_normal_get) + __swig_getmethods__["progress"] = LeapPython.CircleGesture_progress_get + if _newclass:progress = _swig_property(LeapPython.CircleGesture_progress_get) + __swig_getmethods__["radius"] = LeapPython.CircleGesture_radius_get + if _newclass:radius = _swig_property(LeapPython.CircleGesture_radius_get) + __swig_getmethods__["pointable"] = LeapPython.CircleGesture_pointable_get + if _newclass:pointable = _swig_property(LeapPython.CircleGesture_pointable_get) + __swig_destroy__ = LeapPython.delete_CircleGesture + __del__ = lambda self : None; +CircleGesture_swigregister = LeapPython.CircleGesture_swigregister +CircleGesture_swigregister(CircleGesture) + +def CircleGesture_class_type(): + return LeapPython.CircleGesture_class_type() +CircleGesture_class_type = LeapPython.CircleGesture_class_type + +class ScreenTapGesture(Gesture): + __swig_setmethods__ = {} + for _s in [Gesture]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, ScreenTapGesture, name, value) + __swig_getmethods__ = {} + for _s in [Gesture]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, ScreenTapGesture, name) + __repr__ = _swig_repr + __swig_getmethods__["class_type"] = lambda x: LeapPython.ScreenTapGesture_class_type + if _newclass:class_type = staticmethod(LeapPython.ScreenTapGesture_class_type) + def __init__(self, *args): + this = LeapPython.new_ScreenTapGesture(*args) + try: self.this.append(this) + except: self.this = this + __swig_getmethods__["position"] = LeapPython.ScreenTapGesture_position_get + if _newclass:position = _swig_property(LeapPython.ScreenTapGesture_position_get) + __swig_getmethods__["direction"] = LeapPython.ScreenTapGesture_direction_get + if _newclass:direction = _swig_property(LeapPython.ScreenTapGesture_direction_get) + __swig_getmethods__["progress"] = LeapPython.ScreenTapGesture_progress_get + if _newclass:progress = _swig_property(LeapPython.ScreenTapGesture_progress_get) + __swig_getmethods__["pointable"] = LeapPython.ScreenTapGesture_pointable_get + if _newclass:pointable = _swig_property(LeapPython.ScreenTapGesture_pointable_get) + __swig_destroy__ = LeapPython.delete_ScreenTapGesture + __del__ = lambda self : None; +ScreenTapGesture_swigregister = LeapPython.ScreenTapGesture_swigregister +ScreenTapGesture_swigregister(ScreenTapGesture) + +def ScreenTapGesture_class_type(): + return LeapPython.ScreenTapGesture_class_type() +ScreenTapGesture_class_type = LeapPython.ScreenTapGesture_class_type + +class KeyTapGesture(Gesture): + __swig_setmethods__ = {} + for _s in [Gesture]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, KeyTapGesture, name, value) + __swig_getmethods__ = {} + for _s in [Gesture]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, KeyTapGesture, name) + __repr__ = _swig_repr + __swig_getmethods__["class_type"] = lambda x: LeapPython.KeyTapGesture_class_type + if _newclass:class_type = staticmethod(LeapPython.KeyTapGesture_class_type) + def __init__(self, *args): + this = LeapPython.new_KeyTapGesture(*args) + try: self.this.append(this) + except: self.this = this + __swig_getmethods__["position"] = LeapPython.KeyTapGesture_position_get + if _newclass:position = _swig_property(LeapPython.KeyTapGesture_position_get) + __swig_getmethods__["direction"] = LeapPython.KeyTapGesture_direction_get + if _newclass:direction = _swig_property(LeapPython.KeyTapGesture_direction_get) + __swig_getmethods__["progress"] = LeapPython.KeyTapGesture_progress_get + if _newclass:progress = _swig_property(LeapPython.KeyTapGesture_progress_get) + __swig_getmethods__["pointable"] = LeapPython.KeyTapGesture_pointable_get + if _newclass:pointable = _swig_property(LeapPython.KeyTapGesture_pointable_get) + __swig_destroy__ = LeapPython.delete_KeyTapGesture + __del__ = lambda self : None; +KeyTapGesture_swigregister = LeapPython.KeyTapGesture_swigregister +KeyTapGesture_swigregister(KeyTapGesture) + +def KeyTapGesture_class_type(): + return LeapPython.KeyTapGesture_class_type() +KeyTapGesture_class_type = LeapPython.KeyTapGesture_class_type + +class Screen(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, Screen, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, Screen, name) + __repr__ = _swig_repr + def __init__(self): + this = LeapPython.new_Screen() + try: self.this.append(this) + except: self.this = this + def intersect(self, *args): return LeapPython.Screen_intersect(self, *args) + def project(self, *args): return LeapPython.Screen_project(self, *args) + def normal(self): return LeapPython.Screen_normal(self) + def distance_to_point(self, *args): return LeapPython.Screen_distance_to_point(self, *args) + def __eq__(self, *args): return LeapPython.Screen___eq__(self, *args) + def __ne__(self, *args): return LeapPython.Screen___ne__(self, *args) + def __str__(self): return LeapPython.Screen___str__(self) + __swig_getmethods__["id"] = LeapPython.Screen_id_get + if _newclass:id = _swig_property(LeapPython.Screen_id_get) + __swig_getmethods__["horizontal_axis"] = LeapPython.Screen_horizontal_axis_get + if _newclass:horizontal_axis = _swig_property(LeapPython.Screen_horizontal_axis_get) + __swig_getmethods__["vertical_axis"] = LeapPython.Screen_vertical_axis_get + if _newclass:vertical_axis = _swig_property(LeapPython.Screen_vertical_axis_get) + __swig_getmethods__["bottom_left_corner"] = LeapPython.Screen_bottom_left_corner_get + if _newclass:bottom_left_corner = _swig_property(LeapPython.Screen_bottom_left_corner_get) + __swig_getmethods__["width_pixels"] = LeapPython.Screen_width_pixels_get + if _newclass:width_pixels = _swig_property(LeapPython.Screen_width_pixels_get) + __swig_getmethods__["height_pixels"] = LeapPython.Screen_height_pixels_get + if _newclass:height_pixels = _swig_property(LeapPython.Screen_height_pixels_get) + __swig_getmethods__["is_valid"] = LeapPython.Screen_is_valid_get + if _newclass:is_valid = _swig_property(LeapPython.Screen_is_valid_get) + __swig_destroy__ = LeapPython.delete_Screen + __del__ = lambda self : None; +Screen_swigregister = LeapPython.Screen_swigregister +Screen_swigregister(Screen) +Screen.invalid = LeapPython.cvar.Screen_invalid + +class Device(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, Device, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, Device, name) + __repr__ = _swig_repr + def __init__(self): + this = LeapPython.new_Device() + try: self.this.append(this) + except: self.this = this + def distance_to_boundary(self, *args): return LeapPython.Device_distance_to_boundary(self, *args) + def __eq__(self, *args): return LeapPython.Device___eq__(self, *args) + def __ne__(self, *args): return LeapPython.Device___ne__(self, *args) + def __str__(self): return LeapPython.Device___str__(self) + __swig_getmethods__["horizontal_view_angle"] = LeapPython.Device_horizontal_view_angle_get + if _newclass:horizontal_view_angle = _swig_property(LeapPython.Device_horizontal_view_angle_get) + __swig_getmethods__["vertical_view_angle"] = LeapPython.Device_vertical_view_angle_get + if _newclass:vertical_view_angle = _swig_property(LeapPython.Device_vertical_view_angle_get) + __swig_getmethods__["range"] = LeapPython.Device_range_get + if _newclass:range = _swig_property(LeapPython.Device_range_get) + __swig_getmethods__["is_valid"] = LeapPython.Device_is_valid_get + if _newclass:is_valid = _swig_property(LeapPython.Device_is_valid_get) + __swig_destroy__ = LeapPython.delete_Device + __del__ = lambda self : None; +Device_swigregister = LeapPython.Device_swigregister +Device_swigregister(Device) +Device.invalid = LeapPython.cvar.Device_invalid + +class PointableList(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, PointableList, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, PointableList, name) + __repr__ = _swig_repr + def __init__(self): + this = LeapPython.new_PointableList() + try: self.this.append(this) + except: self.this = this + def __len__(self): return LeapPython.PointableList___len__(self) + def __getitem__(self, *args): return LeapPython.PointableList___getitem__(self, *args) + def append(self, *args): return LeapPython.PointableList_append(self, *args) + __swig_getmethods__["is_empty"] = LeapPython.PointableList_is_empty_get + if _newclass:is_empty = _swig_property(LeapPython.PointableList_is_empty_get) + __swig_getmethods__["empty"] = LeapPython.PointableList_empty_get + if _newclass:empty = _swig_property(LeapPython.PointableList_empty_get) + __swig_getmethods__["leftmost"] = LeapPython.PointableList_leftmost_get + if _newclass:leftmost = _swig_property(LeapPython.PointableList_leftmost_get) + __swig_getmethods__["rightmost"] = LeapPython.PointableList_rightmost_get + if _newclass:rightmost = _swig_property(LeapPython.PointableList_rightmost_get) + __swig_getmethods__["frontmost"] = LeapPython.PointableList_frontmost_get + if _newclass:frontmost = _swig_property(LeapPython.PointableList_frontmost_get) + def __iter__(self): + _pos = 0 + while _pos < len(self): + yield self[_pos] + _pos += 1 + + __swig_destroy__ = LeapPython.delete_PointableList + __del__ = lambda self : None; +PointableList_swigregister = LeapPython.PointableList_swigregister +PointableList_swigregister(PointableList) + +class FingerList(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, FingerList, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, FingerList, name) + __repr__ = _swig_repr + def __init__(self): + this = LeapPython.new_FingerList() + try: self.this.append(this) + except: self.this = this + def __len__(self): return LeapPython.FingerList___len__(self) + def __getitem__(self, *args): return LeapPython.FingerList___getitem__(self, *args) + def append(self, *args): return LeapPython.FingerList_append(self, *args) + __swig_getmethods__["is_empty"] = LeapPython.FingerList_is_empty_get + if _newclass:is_empty = _swig_property(LeapPython.FingerList_is_empty_get) + __swig_getmethods__["empty"] = LeapPython.FingerList_empty_get + if _newclass:empty = _swig_property(LeapPython.FingerList_empty_get) + __swig_getmethods__["leftmost"] = LeapPython.FingerList_leftmost_get + if _newclass:leftmost = _swig_property(LeapPython.FingerList_leftmost_get) + __swig_getmethods__["rightmost"] = LeapPython.FingerList_rightmost_get + if _newclass:rightmost = _swig_property(LeapPython.FingerList_rightmost_get) + __swig_getmethods__["frontmost"] = LeapPython.FingerList_frontmost_get + if _newclass:frontmost = _swig_property(LeapPython.FingerList_frontmost_get) + def __iter__(self): + _pos = 0 + while _pos < len(self): + yield self[_pos] + _pos += 1 + + __swig_destroy__ = LeapPython.delete_FingerList + __del__ = lambda self : None; +FingerList_swigregister = LeapPython.FingerList_swigregister +FingerList_swigregister(FingerList) + +class ToolList(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, ToolList, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, ToolList, name) + __repr__ = _swig_repr + def __init__(self): + this = LeapPython.new_ToolList() + try: self.this.append(this) + except: self.this = this + def __len__(self): return LeapPython.ToolList___len__(self) + def __getitem__(self, *args): return LeapPython.ToolList___getitem__(self, *args) + def append(self, *args): return LeapPython.ToolList_append(self, *args) + __swig_getmethods__["is_empty"] = LeapPython.ToolList_is_empty_get + if _newclass:is_empty = _swig_property(LeapPython.ToolList_is_empty_get) + __swig_getmethods__["empty"] = LeapPython.ToolList_empty_get + if _newclass:empty = _swig_property(LeapPython.ToolList_empty_get) + __swig_getmethods__["leftmost"] = LeapPython.ToolList_leftmost_get + if _newclass:leftmost = _swig_property(LeapPython.ToolList_leftmost_get) + __swig_getmethods__["rightmost"] = LeapPython.ToolList_rightmost_get + if _newclass:rightmost = _swig_property(LeapPython.ToolList_rightmost_get) + __swig_getmethods__["frontmost"] = LeapPython.ToolList_frontmost_get + if _newclass:frontmost = _swig_property(LeapPython.ToolList_frontmost_get) + def __iter__(self): + _pos = 0 + while _pos < len(self): + yield self[_pos] + _pos += 1 + + __swig_destroy__ = LeapPython.delete_ToolList + __del__ = lambda self : None; +ToolList_swigregister = LeapPython.ToolList_swigregister +ToolList_swigregister(ToolList) + +class HandList(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, HandList, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, HandList, name) + __repr__ = _swig_repr + def __init__(self): + this = LeapPython.new_HandList() + try: self.this.append(this) + except: self.this = this + def __len__(self): return LeapPython.HandList___len__(self) + def __getitem__(self, *args): return LeapPython.HandList___getitem__(self, *args) + def append(self, *args): return LeapPython.HandList_append(self, *args) + __swig_getmethods__["is_empty"] = LeapPython.HandList_is_empty_get + if _newclass:is_empty = _swig_property(LeapPython.HandList_is_empty_get) + __swig_getmethods__["empty"] = LeapPython.HandList_empty_get + if _newclass:empty = _swig_property(LeapPython.HandList_empty_get) + __swig_getmethods__["leftmost"] = LeapPython.HandList_leftmost_get + if _newclass:leftmost = _swig_property(LeapPython.HandList_leftmost_get) + __swig_getmethods__["rightmost"] = LeapPython.HandList_rightmost_get + if _newclass:rightmost = _swig_property(LeapPython.HandList_rightmost_get) + __swig_getmethods__["frontmost"] = LeapPython.HandList_frontmost_get + if _newclass:frontmost = _swig_property(LeapPython.HandList_frontmost_get) + def __iter__(self): + _pos = 0 + while _pos < len(self): + yield self[_pos] + _pos += 1 + + __swig_destroy__ = LeapPython.delete_HandList + __del__ = lambda self : None; +HandList_swigregister = LeapPython.HandList_swigregister +HandList_swigregister(HandList) + +class GestureList(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, GestureList, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, GestureList, name) + __repr__ = _swig_repr + def __init__(self): + this = LeapPython.new_GestureList() + try: self.this.append(this) + except: self.this = this + def __len__(self): return LeapPython.GestureList___len__(self) + def __getitem__(self, *args): return LeapPython.GestureList___getitem__(self, *args) + def append(self, *args): return LeapPython.GestureList_append(self, *args) + __swig_getmethods__["is_empty"] = LeapPython.GestureList_is_empty_get + if _newclass:is_empty = _swig_property(LeapPython.GestureList_is_empty_get) + __swig_getmethods__["empty"] = LeapPython.GestureList_empty_get + if _newclass:empty = _swig_property(LeapPython.GestureList_empty_get) + def __iter__(self): + _pos = 0 + while _pos < len(self): + yield self[_pos] + _pos += 1 + + __swig_destroy__ = LeapPython.delete_GestureList + __del__ = lambda self : None; +GestureList_swigregister = LeapPython.GestureList_swigregister +GestureList_swigregister(GestureList) + +class ScreenList(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, ScreenList, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, ScreenList, name) + __repr__ = _swig_repr + def __init__(self): + this = LeapPython.new_ScreenList() + try: self.this.append(this) + except: self.this = this + def __len__(self): return LeapPython.ScreenList___len__(self) + def __getitem__(self, *args): return LeapPython.ScreenList___getitem__(self, *args) + def closest_screen_hit(self, *args): return LeapPython.ScreenList_closest_screen_hit(self, *args) + def closest_screen(self, *args): return LeapPython.ScreenList_closest_screen(self, *args) + __swig_getmethods__["is_empty"] = LeapPython.ScreenList_is_empty_get + if _newclass:is_empty = _swig_property(LeapPython.ScreenList_is_empty_get) + __swig_getmethods__["empty"] = LeapPython.ScreenList_empty_get + if _newclass:empty = _swig_property(LeapPython.ScreenList_empty_get) + def __iter__(self): + _pos = 0 + while _pos < len(self): + yield self[_pos] + _pos += 1 + + __swig_destroy__ = LeapPython.delete_ScreenList + __del__ = lambda self : None; +ScreenList_swigregister = LeapPython.ScreenList_swigregister +ScreenList_swigregister(ScreenList) + +class DeviceList(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, DeviceList, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, DeviceList, name) + __repr__ = _swig_repr + def __init__(self): + this = LeapPython.new_DeviceList() + try: self.this.append(this) + except: self.this = this + def __len__(self): return LeapPython.DeviceList___len__(self) + def __getitem__(self, *args): return LeapPython.DeviceList___getitem__(self, *args) + def append(self, *args): return LeapPython.DeviceList_append(self, *args) + __swig_getmethods__["is_empty"] = LeapPython.DeviceList_is_empty_get + if _newclass:is_empty = _swig_property(LeapPython.DeviceList_is_empty_get) + def __iter__(self): + _pos = 0 + while _pos < len(self): + yield self[_pos] + _pos += 1 + + __swig_destroy__ = LeapPython.delete_DeviceList + __del__ = lambda self : None; +DeviceList_swigregister = LeapPython.DeviceList_swigregister +DeviceList_swigregister(DeviceList) + +class InteractionBox(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, InteractionBox, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, InteractionBox, name) + __repr__ = _swig_repr + def __init__(self): + this = LeapPython.new_InteractionBox() + try: self.this.append(this) + except: self.this = this + def normalize_point(self, *args): return LeapPython.InteractionBox_normalize_point(self, *args) + def denormalize_point(self, *args): return LeapPython.InteractionBox_denormalize_point(self, *args) + def __eq__(self, *args): return LeapPython.InteractionBox___eq__(self, *args) + def __ne__(self, *args): return LeapPython.InteractionBox___ne__(self, *args) + def __str__(self): return LeapPython.InteractionBox___str__(self) + __swig_getmethods__["center"] = LeapPython.InteractionBox_center_get + if _newclass:center = _swig_property(LeapPython.InteractionBox_center_get) + __swig_getmethods__["width"] = LeapPython.InteractionBox_width_get + if _newclass:width = _swig_property(LeapPython.InteractionBox_width_get) + __swig_getmethods__["height"] = LeapPython.InteractionBox_height_get + if _newclass:height = _swig_property(LeapPython.InteractionBox_height_get) + __swig_getmethods__["depth"] = LeapPython.InteractionBox_depth_get + if _newclass:depth = _swig_property(LeapPython.InteractionBox_depth_get) + __swig_getmethods__["is_valid"] = LeapPython.InteractionBox_is_valid_get + if _newclass:is_valid = _swig_property(LeapPython.InteractionBox_is_valid_get) + __swig_destroy__ = LeapPython.delete_InteractionBox + __del__ = lambda self : None; +InteractionBox_swigregister = LeapPython.InteractionBox_swigregister +InteractionBox_swigregister(InteractionBox) +InteractionBox.invalid = LeapPython.cvar.InteractionBox_invalid + +class Frame(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, Frame, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, Frame, name) + __repr__ = _swig_repr + def __init__(self): + this = LeapPython.new_Frame() + try: self.this.append(this) + except: self.this = this + def hand(self, *args): return LeapPython.Frame_hand(self, *args) + def pointable(self, *args): return LeapPython.Frame_pointable(self, *args) + def finger(self, *args): return LeapPython.Frame_finger(self, *args) + def tool(self, *args): return LeapPython.Frame_tool(self, *args) + def gesture(self, *args): return LeapPython.Frame_gesture(self, *args) + def gestures(self, *args): return LeapPython.Frame_gestures(self, *args) + def translation(self, *args): return LeapPython.Frame_translation(self, *args) + def translation_probability(self, *args): return LeapPython.Frame_translation_probability(self, *args) + def rotation_axis(self, *args): return LeapPython.Frame_rotation_axis(self, *args) + def rotation_angle(self, *args): return LeapPython.Frame_rotation_angle(self, *args) + def rotation_matrix(self, *args): return LeapPython.Frame_rotation_matrix(self, *args) + def rotation_probability(self, *args): return LeapPython.Frame_rotation_probability(self, *args) + def scale_factor(self, *args): return LeapPython.Frame_scale_factor(self, *args) + def scale_probability(self, *args): return LeapPython.Frame_scale_probability(self, *args) + def __eq__(self, *args): return LeapPython.Frame___eq__(self, *args) + def __ne__(self, *args): return LeapPython.Frame___ne__(self, *args) + def __str__(self): return LeapPython.Frame___str__(self) + __swig_getmethods__["id"] = LeapPython.Frame_id_get + if _newclass:id = _swig_property(LeapPython.Frame_id_get) + __swig_getmethods__["timestamp"] = LeapPython.Frame_timestamp_get + if _newclass:timestamp = _swig_property(LeapPython.Frame_timestamp_get) + __swig_getmethods__["current_frames_per_second"] = LeapPython.Frame_current_frames_per_second_get + if _newclass:current_frames_per_second = _swig_property(LeapPython.Frame_current_frames_per_second_get) + __swig_getmethods__["pointables"] = LeapPython.Frame_pointables_get + if _newclass:pointables = _swig_property(LeapPython.Frame_pointables_get) + __swig_getmethods__["fingers"] = LeapPython.Frame_fingers_get + if _newclass:fingers = _swig_property(LeapPython.Frame_fingers_get) + __swig_getmethods__["tools"] = LeapPython.Frame_tools_get + if _newclass:tools = _swig_property(LeapPython.Frame_tools_get) + __swig_getmethods__["hands"] = LeapPython.Frame_hands_get + if _newclass:hands = _swig_property(LeapPython.Frame_hands_get) + __swig_getmethods__["is_valid"] = LeapPython.Frame_is_valid_get + if _newclass:is_valid = _swig_property(LeapPython.Frame_is_valid_get) + __swig_getmethods__["interaction_box"] = LeapPython.Frame_interaction_box_get + if _newclass:interaction_box = _swig_property(LeapPython.Frame_interaction_box_get) + __swig_destroy__ = LeapPython.delete_Frame + __del__ = lambda self : None; +Frame_swigregister = LeapPython.Frame_swigregister +Frame_swigregister(Frame) +Frame.invalid = LeapPython.cvar.Frame_invalid + +class Config(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, Config, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, Config, name) + __repr__ = _swig_repr + def __init__(self): + this = LeapPython.new_Config() + try: self.this.append(this) + except: self.this = this + TYPE_UNKNOWN = LeapPython.Config_TYPE_UNKNOWN + TYPE_BOOLEAN = LeapPython.Config_TYPE_BOOLEAN + TYPE_INT32 = LeapPython.Config_TYPE_INT32 + TYPE_FLOAT = LeapPython.Config_TYPE_FLOAT + TYPE_STRING = LeapPython.Config_TYPE_STRING + + + + + + + + + + def save(self): return LeapPython.Config_save(self) + def get(self, *args): + type = LeapPython.Config_type(self, *args) + if type == LeapPython.Config_TYPE_BOOLEAN: + return LeapPython.Config_get_bool(self, *args) + elif type == LeapPython.Config_TYPE_INT32: + return LeapPython.Config_get_int_32(self, *args) + elif type == LeapPython.Config_TYPE_FLOAT: + return LeapPython.Config_get_float(self, *args) + elif type == LeapPython.Config_TYPE_STRING: + return LeapPython.Config_get_string(self, *args) + return None + def set(self, *args): + type = LeapPython.Config_type(self, *args[:-1]) # Do not pass value through + if type == LeapPython.Config_TYPE_BOOLEAN: + return LeapPython.Config_set_bool(self, *args) + elif type == LeapPython.Config_TYPE_INT32: + return LeapPython.Config_set_int_32(self, *args) + elif type == LeapPython.Config_TYPE_FLOAT: + return LeapPython.Config_set_float(self, *args) + elif type == LeapPython.Config_TYPE_STRING: + return LeapPython.Config_set_string(self, *args) + return False + + __swig_destroy__ = LeapPython.delete_Config + __del__ = lambda self : None; +Config_swigregister = LeapPython.Config_swigregister +Config_swigregister(Config) + +class Controller(Interface): + __swig_setmethods__ = {} + for _s in [Interface]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, Controller, name, value) + __swig_getmethods__ = {} + for _s in [Interface]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, Controller, name) + __repr__ = _swig_repr + __swig_destroy__ = LeapPython.delete_Controller + __del__ = lambda self : None; + def __init__(self, *args): + this = LeapPython.new_Controller(*args) + try: self.this.append(this) + except: self.this = this + POLICY_DEFAULT = LeapPython.Controller_POLICY_DEFAULT + POLICY_BACKGROUND_FRAMES = LeapPython.Controller_POLICY_BACKGROUND_FRAMES + def set_policy_flags(self, *args): return LeapPython.Controller_set_policy_flags(self, *args) + def add_listener(self, *args): return LeapPython.Controller_add_listener(self, *args) + def remove_listener(self, *args): return LeapPython.Controller_remove_listener(self, *args) + def frame(self, history=0): return LeapPython.Controller_frame(self, history) + def enable_gesture(self, *args): return LeapPython.Controller_enable_gesture(self, *args) + def is_gesture_enabled(self, *args): return LeapPython.Controller_is_gesture_enabled(self, *args) + __swig_getmethods__["is_connected"] = LeapPython.Controller_is_connected_get + if _newclass:is_connected = _swig_property(LeapPython.Controller_is_connected_get) + __swig_getmethods__["has_focus"] = LeapPython.Controller_has_focus_get + if _newclass:has_focus = _swig_property(LeapPython.Controller_has_focus_get) + __swig_getmethods__["policy_flags"] = LeapPython.Controller_policy_flags_get + if _newclass:policy_flags = _swig_property(LeapPython.Controller_policy_flags_get) + __swig_getmethods__["config"] = LeapPython.Controller_config_get + if _newclass:config = _swig_property(LeapPython.Controller_config_get) + __swig_getmethods__["located_screens"] = LeapPython.Controller_located_screens_get + if _newclass:located_screens = _swig_property(LeapPython.Controller_located_screens_get) + __swig_getmethods__["calibrated_screens"] = LeapPython.Controller_calibrated_screens_get + if _newclass:calibrated_screens = _swig_property(LeapPython.Controller_calibrated_screens_get) + __swig_getmethods__["devices"] = LeapPython.Controller_devices_get + if _newclass:devices = _swig_property(LeapPython.Controller_devices_get) +Controller_swigregister = LeapPython.Controller_swigregister +Controller_swigregister(Controller) + +class Listener(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, Listener, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, Listener, name) + __repr__ = _swig_repr + def __init__(self): + if self.__class__ == Listener: + _self = None + else: + _self = self + this = LeapPython.new_Listener(_self, ) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = LeapPython.delete_Listener + __del__ = lambda self : None; + def on_init(self, *args): return LeapPython.Listener_on_init(self, *args) + def on_connect(self, *args): return LeapPython.Listener_on_connect(self, *args) + def on_disconnect(self, *args): return LeapPython.Listener_on_disconnect(self, *args) + def on_exit(self, *args): return LeapPython.Listener_on_exit(self, *args) + def on_frame(self, *args): return LeapPython.Listener_on_frame(self, *args) + def on_focus_gained(self, *args): return LeapPython.Listener_on_focus_gained(self, *args) + def on_focus_lost(self, *args): return LeapPython.Listener_on_focus_lost(self, *args) + def __disown__(self): + self.this.disown() + LeapPython.disown_Listener(self) + return weakref_proxy(self) +Listener_swigregister = LeapPython.Listener_swigregister +Listener_swigregister(Listener) + +# This file is compatible with both classic and new-style classes. + + diff --git a/PoC/leap/LeapPython.so b/PoC/leap/LeapPython.so new file mode 100755 index 0000000..9120851 Binary files /dev/null and b/PoC/leap/LeapPython.so differ diff --git a/PoC/leap/Sample-Vanilla.py b/PoC/leap/Sample-Vanilla.py new file mode 100755 index 0000000..b65869a --- /dev/null +++ b/PoC/leap/Sample-Vanilla.py @@ -0,0 +1,142 @@ +#!/usr/bin/python +################################################################################ +# Copyright (C) 2012-2013 Leap Motion, Inc. All rights reserved. # +# Leap Motion proprietary and confidential. Not for distribution. # +# Use subject to the terms of the Leap Motion SDK Agreement available at # +# https://developer.leapmotion.com/sdk_agreement, or another agreement # +# between Leap Motion and you, your company or other organization. # +################################################################################ + +import Leap, sys +from Leap import CircleGesture, KeyTapGesture, ScreenTapGesture, SwipeGesture + + +class SampleListener(Leap.Listener): + def on_init(self, controller): + print "Initialized" + + def on_connect(self, controller): + print "Connected" + + # Enable gestures + 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): + # Note: not dispatched when running in a debugger. + print "Disconnected" + + def on_exit(self, controller): + print "Exited" + + def on_frame(self, controller): + # Get the most recent frame and report some basic information + frame = controller.frame() + + print "Frame id: %d, timestamp: %d, hands: %d, fingers: %d, tools: %d, gestures: %d" % ( + frame.id, frame.timestamp, len(frame.hands), len(frame.fingers), len(frame.tools), len(frame.gestures())) + + if not frame.hands.empty: + # Get the first hand + hand = frame.hands[0] + + # Check if the hand has any fingers + fingers = hand.fingers + if not fingers.empty: + # Calculate the hand's average finger tip position + avg_pos = Leap.Vector() + for finger in fingers: + avg_pos += finger.tip_position + avg_pos /= len(fingers) + print "Hand has %d fingers, average finger tip position: %s" % ( + len(fingers), avg_pos) + + # Get the hand's sphere radius and palm position + print "Hand sphere radius: %f mm, palm position: %s" % ( + hand.sphere_radius, hand.palm_position) + + # Get the hand's normal vector and direction + normal = hand.palm_normal + direction = hand.direction + + # Calculate the hand's pitch, roll, and yaw angles + print "Hand pitch: %f degrees, roll: %f degrees, yaw: %f degrees" % ( + direction.pitch * Leap.RAD_TO_DEG, + normal.roll * Leap.RAD_TO_DEG, + direction.yaw * Leap.RAD_TO_DEG) + + # Gestures + for gesture in frame.gestures(): + if gesture.type == Leap.Gesture.TYPE_CIRCLE: + circle = CircleGesture(gesture) + + # Determine clock direction using the angle between the pointable and the circle normal + if circle.pointable.direction.angle_to(circle.normal) <= Leap.PI/4: + clockwiseness = "clockwise" + else: + clockwiseness = "counterclockwise" + + # Calculate the angle swept since the last frame + swept_angle = 0 + if circle.state != Leap.Gesture.STATE_START: + previous_update = CircleGesture(controller.frame(1).gesture(circle.id)) + swept_angle = (circle.progress - previous_update.progress) * 2 * Leap.PI + + print "Circle id: %d, %s, progress: %f, radius: %f, angle: %f degrees, %s" % ( + gesture.id, self.state_string(gesture.state), + circle.progress, circle.radius, swept_angle * Leap.RAD_TO_DEG, clockwiseness) + + if gesture.type == Leap.Gesture.TYPE_SWIPE: + swipe = SwipeGesture(gesture) + print "Swipe id: %d, state: %s, position: %s, direction: %s, speed: %f" % ( + gesture.id, self.state_string(gesture.state), + swipe.position, swipe.direction, swipe.speed) + + if gesture.type == Leap.Gesture.TYPE_KEY_TAP: + keytap = KeyTapGesture(gesture) + print "Key Tap id: %d, %s, position: %s, direction: %s" % ( + gesture.id, self.state_string(gesture.state), + keytap.position, keytap.direction ) + + if gesture.type == Leap.Gesture.TYPE_SCREEN_TAP: + screentap = ScreenTapGesture(gesture) + print "Screen Tap id: %d, %s, position: %s, direction: %s" % ( + gesture.id, self.state_string(gesture.state), + screentap.position, screentap.direction ) + + if not (frame.hands.empty and frame.gestures().empty): + print "" + + def state_string(self, state): + if state == Leap.Gesture.STATE_START: + return "STATE_START" + + if state == Leap.Gesture.STATE_UPDATE: + return "STATE_UPDATE" + + if state == Leap.Gesture.STATE_STOP: + return "STATE_STOP" + + if state == Leap.Gesture.STATE_INVALID: + return "STATE_INVALID" + +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..." + sys.stdin.readline() + + # Remove the sample listener when done + controller.remove_listener(listener) + + +if __name__ == "__main__": + main() diff --git a/PoC/leap/leap.ino b/PoC/leap/leap.ino new file mode 100644 index 0000000..51d0bd2 --- /dev/null +++ b/PoC/leap/leap.ino @@ -0,0 +1,220 @@ +// testcolors demo for RGBmatrixPanel library. +// Renders 512 colors on a 16x32 RGB LED matrix. +// Library supports 4096 colors, but there aren't that many pixels! + +#include // Core graphics library +#include // Hardware-specific library + +#define CLK 8 // MUST be on PORTB! +#define LAT A3 +#define OE 9 +#define A A0 +#define B A1 +#define C A2 +RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false); +int incomingByte = 0; // for incoming serial data + +void setup() { + matrix.begin(); + Serial.begin(9600); + //myWindows(random(1,21)); + int window = 13; + int brightness = 255; + int del = 100; + // White is 7,7,7 (3bit) 255,255,255 (8bit) + uint8_t red=255, green=255, blue=255; + int w_init[] = { 1, 7, 13, 19, 15 }; + int w_jump[] = { 15, 14, 13, 12, 11, 11, 12, 13, 14, 15 }; + + +while ( true ) { + // Initialize field + for (int i=0; i < 5; i++) { + myWindows(w_init[i], brightness, red, green, blue); + delay(del-20); + } + //myWindows(16, brightness, red, green, blue); + // fill the screen with 'black' + matrix.fillScreen(matrix.Color888(0, 0, 0)); + matrix.swapBuffers(false); + +// myWindows(15, brightness, red, green, blue); + + Serial.println("rdy"); + + // 48 == 0 -- 49 == 1 + // send data only when you receive data: + while (incomingByte != 57 ) { + //Serial.println("Waiting :)"); + if (Serial.available() > 0) { + // read the incoming byte: + incomingByte = Serial.read(); + switch (incomingByte){ + // No hands or Fist + case 48: + matrix.fillScreen(matrix.Color888(0, 0, 0)); + break; + // One Hand + case 49: + myWindows(5, brightness, 0, 0, 0); + myWindows(10, brightness, 0, 0, 0); + myWindows(15, brightness, red, green, blue); + myWindows(20, brightness, 0, 0, 0); + break; + // Two hands, two balls + case 50: + myWindows(5, brightness, 0, 0, 0); + myWindows(10, brightness, 0, 0, 0); + myWindows(15, brightness, red, green, blue); + myWindows(20, brightness, red, green, blue); + break; + // Make ball jump + case 51: + for (int i=0; i < 11; i++) { + myWindows(w_jump[i], brightness, red, green, blue); + delay(del); + matrix.fillScreen(matrix.Color888(0, 0, 0)); + } + myWindows(15, brightness, red, green, blue); + break; + // Move ball horizontally w5 + case 52: + myWindows(5, brightness, red, green, blue); + myWindows(15, brightness, 0, 0, 0); + myWindows(10, brightness, 0, 0, 0); + myWindows(20, brightness, 0, 0, 0); + break; + // Move ball horizontally w10 + case 53: + myWindows(5, brightness, 0, 0, 0); + myWindows(10, brightness, red, green, blue); + myWindows(15, brightness, 0, 0, 0); + myWindows(20, brightness, 0, 0, 0); + break; + // Move ball horizontally w15 + case 54: + myWindows(5, brightness, 0, 0, 0); + myWindows(10, brightness, 0, 0, 0); + myWindows(15, brightness, red, green, blue); + myWindows(20, brightness, 0, 0, 0); + break; + // Move ball horizontally w20 + case 55: + myWindows(5, brightness, 0, 0, 0); + myWindows(15, brightness, 0, 0, 0); + myWindows(10, brightness, 0, 0, 0); + myWindows(20, brightness, red, green, blue); + break; + default: + matrix.fillScreen(matrix.Color888(0, 0, 0)); + break; + } + // say what you got: + //Serial.print("I received: "); + //Serial.println(incomingByte, DEC); + } + delay(100); + } + incomingByte=0; + myWindows(5, brightness, red, green, blue); + myWindows(10, brightness, red, green, blue); + myWindows(15, brightness, red, green, blue); + myWindows(20, brightness, red, green, blue); + delay(10000); +} + +} + +int myWindows (int w, int br, int r, int g, int b){ + +switch (w) { + case 1: + // Window 1 + matrix.fillRect(1,12,4,3, matrix.Color888(r,g,b)); + break; + case 2: + // Window 2 + matrix.fillRect(7,12,4,3, matrix.Color888(r,g,b)); + break; + case 3: + // Window 3 + matrix.fillRect(13,12,4,3, matrix.Color888(r,g,b)); + break; + case 4: + // Window 4 + matrix.fillRect(19,12,4,3, matrix.Color888(r,g,b)); + break; + case 5: + // Window 5 + matrix.fillRect(25,12,4,3, matrix.Color888(r,g,b)); + break; + case 6: + // Window 6 + matrix.fillRect(1,8,4,3, matrix.Color888(r,g,b)); + break; + case 7: + // Window 7 + matrix.fillRect(7,8,4,3, matrix.Color888(r,g,b)); + break; + case 8: + // Window 8 + matrix.fillRect(13,8,4,3, matrix.Color888(r,g,b)); + break; + case 9: + // Window 9 + matrix.fillRect(19,8,4,3, matrix.Color888(r,g,b)); + break; + case 10: + // Window 10 + matrix.fillRect(25,8,4,3, matrix.Color888(r,g,b)); + break; + case 11: + // Window 11 + matrix.fillRect(1,4,4,3, matrix.Color888(r,g,b)); + break; + case 12: + // Window 12 + matrix.fillRect(7,4,4,3, matrix.Color888(r,g,b)); + break; + case 13: + // Window 13 + matrix.fillRect(13,4,4,3, matrix.Color888(r,g,b)); + break; + case 14: + // Window 14 + matrix.fillRect(19,4,4,3, matrix.Color888(r,g,b)); + break; + case 15: + // Window 15 + matrix.fillRect(25,4,4,3, matrix.Color888(r,g,b)); + break; + case 16: + // Window 16 + matrix.fillRect(1,0,4,3, matrix.Color888(r,g,b)); + break; + case 17: + // Window 17 + matrix.fillRect(7,0,4,3, matrix.Color888(r,g,b)); + break; + case 18: + // Window 18 + matrix.fillRect(13,0,4,3, matrix.Color888(r,g,b)); + break; + case 19: + // Window 19 + matrix.fillRect(19,0,4,3, matrix.Color888(r,g,b)); + break; + case 20: + // Window 20 + matrix.fillRect(25,0,4,3, matrix.Color888(r,g,b)); + break; + + default: + break; +} + } + +void loop() { + // do nothing +} + diff --git a/PoC/leap/libLeap.dylib b/PoC/leap/libLeap.dylib new file mode 100755 index 0000000..683a604 Binary files /dev/null and b/PoC/leap/libLeap.dylib differ