The Leap Screen freature isn't available in the newest update.
The newest update in the Leap API disables the screen feature and makes the screen API unavailable. Therefore, users that would like to use the default feature of using their finger for the PyLeapMouse script are left with an error message: Please calibrate your Leap screen feature.
There should be some fix to use the field of view from the Leap Motion device as some kind of makeshift screen for this functionality. With it being an inverted pyramid from the POV of the device, it would be kind of difficult to scale the screen to the field of vision from the device. Testing and ease of usage would be concerns for those that use the library as a intermediary point between their device and their screen, but I'm just bringing up this point for the latest update to the leap api.
I have a patch I am willing to contribute after I fork this project to enable mouse movement using a finger in the latest update.
diff --git a/FingerControl.py b/FingerControl.py index 5aa97e7..87eb66f 100755 --- a/FingerControl.py +++ b/FingerControl.py @@ -14,21 +14,13 @@ class Finger_Control_Listener(Leap.Listener): #The Listener that we attach to t super(Finger_Control_Listener, self).init() #Initialize like a normal listener #Initialize a bunch of stuff specific to this implementation self.screen = None
-
self.screen_resolution = (0,0) -
self.screen_resolution = (1920,1080) self.cursor = mouse.absolute_cursor() #The cursor object that lets us control mice cross-p self.mouse_position_smoother = mouse_position_smoother(smooth_aggressiveness, smooth_fallof self.mouse_button_debouncer = debouncer(5) #A signal debouncer that ensures a reliable, no self.most_recent_pointer_finger_id = None #This holds the ID of the most recently used poidef on_init(self, controller):
-
if controller.located_screens.is_empty: -
print "Please calibrate your Leap screen feature." -
sys.exit(0) -
else: -
print "Found a screen..." -
self.screen = controller.located_screens[0]
- self.screen_resolution = (self.screen.width_pixels, self.screen.height_pixels)
print "Initialized"
def on_connect(self, controller):
@@ -42,12 +34,15 @@ class Finger_Control_Listener(Leap.Listener): #The Listener that we attach to t
def on_frame(self, controller):
frame = controller.frame() #Grab the latest 3D data
-
if not frame.hands.is_empty: #Make sure we have some hands to work with -
hand = frame.hands[0] #The first hand -
if has_two_pointer_fingers(hand): #Scroll mode -
self.do_scroll_stuff(hand) -
else: #Mouse mode -
self.do_mouse_stuff(hand) -
finger = frame.fingers.frontmost -
stabilizedPosition = finger.stabilized_tip_position -
interactionBox = frame.interaction_box -
normalizedPosition = interactionBox.normalize_point(stabilizedPosition) -
if(finger.touch_distance > 0 and finger.touch_zone != Leap.Pointable.ZONE_NONE): -
self.cursor.set_left_button_pressed(False) -
elif(finger.touch_distance <= 0): -
self.cursor.set_left_button_pressed(True) -
self.cursor.move(normalizedPosition.x \* self.screen_resolution[0], self.screen_resolution[1] - normalizedPosition.y \* self.screen_resolution[1])
It works, but isn't the greatest implementation so far, you also need to manually set your resolution. Hope someone who is part of this project can tidy it up and make it much better.