-1

I am trying to find out which finger performed KEY_TAP gesture from leap motion controller.

I have this code: missed tap gestures from leap motion in java

Can anyone give an example in JAVA of how to get the finger/fingers (if more than one) that made the gesture ?

Community
  • 1
  • 1
NewbieJav
  • 13
  • 4

1 Answers1

0

The tap gesture have a pointables() method that gives you the tapping pointable -- there will be only one per tap, though you can have multiple fingers tapping at the same time. To identify the finger, you can use the Finger.type() method (after checking that the tapping pointable is a finger -- it could also be a tool). Once you have a list of gestures, you can identify the tapping finger as follows:

for(Gesture gesture : gestures){
  if(gesture.type() == KeyTapGesture.classType()){
    KeyTapGesture keytap = new KeyTapGesture(gesture);
    Pointable tappingPointable = keytap.pointable();
    if(tappingPointable.isFinger()){
      Finger tappingFinger = new Finger(tappingPointable);
      println("Tapper: " + tappingFinger.type());
    }
  }
}
Charles Ward
  • 1,388
  • 1
  • 8
  • 13
  • Thanks ! Working great. Still missing frames though... Is it possible that I'm reading the leap data to slow ? I tried removing the "sleep" part, and even with the last frame remembered, I'm still not getting all the taps. Thanks again ! – NewbieJav Aug 07 '15 at 18:32
  • I'm also seeing on the visualizer that I'm not getting all my taps and sometime, although I tap really long distance, the finger only moves slightly. – NewbieJav Aug 07 '15 at 18:55
  • In the Visualizer you can display gestures by pressing the o-key. If the gestures aren't being shown in the Visualizer, then your app won't get them either. It means the gestures aren't recognized. Your recourse in that case is to play with the gesture parameters to make the taps easier to perform (without making them too easy). – Charles Ward Aug 07 '15 at 20:08
  • If your visualized fingers aren't moving like your real fingers, that usually means that the Leap Cameras don't have a good view of them. A low frame rate can also cause tracking problems. The frame rate should be 40 or (preferably) higher with hands in view. – Charles Ward Aug 07 '15 at 20:12
  • which frame rate ? data or rendered ? That's probably the problem. – NewbieJav Aug 07 '15 at 20:44
  • The data frame rate -- but note that depending on settings, it can lower itself automatically to save power. Look at the frame rate with your hands in view and moving around. – Charles Ward Aug 07 '15 at 22:23
  • I tried to change to another computer - apparently the problem with the data rate was the computer (too wek). Thanks. – NewbieJav Aug 07 '15 at 22:56