openleap / PyLeapMouse

A Leap Motion based mouse in Python
Other
172 stars 65 forks source link

Always 5 fingers for my gesture hand #35

Open JordanPeltier opened 8 years ago

JordanPeltier commented 8 years ago

Hi everyone, I do not know how to click or scroll in palm mode. After adding a few print in the code source, I found my problem : when the leaps detects the second hand (left one), it always recognize 5 fingers instead of 2 or 1. Any ideas about how to fix this problem ?

Cervator commented 8 years ago

Hi @Justidan :-)

Being that the code here is more than two years old I suspect the Leap software has jumped ahead enough to where the original version here may not work too well.

Looking at the network graph I see one fork has moved ahead and has newer code. Maybe check it out and see if that version works differently? https://github.com/comfreeze/PyLeapMouse

JordanPeltier commented 8 years ago

Hi, Actually I found the solution. You have to use the method "extended" in order to remove the non-extended fingers of the list. I probably don't have the same SDK but the latest one. def do_gesture_recognition(self, gesture_hand, mouse_hand): gesture_fingers = gesture_hand.fingers.extended() if len(gesture_fingers) == 2: #Two open fingers on gesture hand (scroll mode) self.gesture_debouncer.signal(2) #Tell the debouncer we've seen this gesture elif len(gesture_fingers) == 1: #One open finger on gesture hand (click down)

Cervator commented 8 years ago

Up for submitting a fix for this issue in a PR then? Or was the fix needed elsewhere? :-)

In any case thanks for the sleuthing! Good to have it documented here if nothing else.