i want to use Leap Motion to get my Index finger Tip position in the space ( 3D position X,Y,Z ) , how can i do that in leap motion ?
this is what i do only to detect index finger, but there an error :
def on_frame(self, controller):
# Get the most recent frame and report some basic information
frame = controller.frame()
finger = Finger.TYPE_INDEX
print('Type : '+finger.type())
time.sleep(3)
i am a leap motion beginner, i want you to guide me how to do that, and if there is any examples or codes ?
thanks :)
First off, have a look at the documentation for the Leap Motion Python API. Then examine the Sample.py program in the SDK samples folder. Sample.py provides an example for getting just about every piece of information available from the API.
For your specific problem above, Finger.TYPE_INDEX
gives you an enumeration or name for the index finger; it does not give you an instance of an object representing the index finger -- there's an index finger for each of your hands and there can be multiple hands in the Leap device's field of view -- so which index finger should it return?
You can get the list of all tracked fingers from frame.fingers()
and the list of the tracked fingers for a particular hand from hand.fingers()
. From these lists, you can filter for a particular type of finger using the name (i.e. Finger.TYPE_INDEX
or TYPE_THUMB
).
def on_frame(self, controller):
# Get the most recent frame and report some basic information
frame = controller.frame()
fingers = frame.fingers()
index_fingers = fingers.finger_type(Finger.TYPE_INDEX)
for(finger in index_fingers):
print('Type : '+finger.type())
time.sleep(3)