"extended" function python in Leap Motion SDK doesn't work

155 views Asked by At

I wish detect the number of fingers extended with Leap Motion. When I try with C++ function, it's ok. But when I want to try with python API, it doesn't work...

This is the code in on_frame function :

f = controller.frame()
l = len(f.fingers.extended())
print("nb = %d" % l)

And in the API reference, the following example is given : extended_finger_list = frame.fingers.extended()

The display is always returned "0"... What the hell ? :'(

1

There are 1 answers

1
poke On BEST ANSWER

The following code works for me with the current SDK (version 2.1.6):

import Leap

class FingerCounter (Leap.Listener):
    def on_frame (self, controller):
        f = controller.frame()
        print(len(f.fingers.extended()))

listener = FingerCounter()

try:
    controller = Leap.Controller()
    controller.add_listener(listener)
    raw_input()
except KeyboardInterrupt:
    pass
finally:
    controller.remove_listener(listener)