2

I'm using the Java LeapMotion SDK 2.2. I want to detect the position of my thumb, to observe if my thumb is moving or not, but I have some polluted informations, I don't know where come these informations.

    for (Finger f : frame.fingers())
    {
        switch (f.type()) 
        {
        case TYPE_THUMB :
             if(f.hand().isRight())
             {
                 System.out.println(" position : (x:" + f.tipPosition().getX() + " , y:" + f.tipPosition().getY() +")");
             }
        }
    }

I have this kind of results (when I don't move my hand and my thumb)...

 position : (x:-42.98356 , y:180.52577)
 position : (x:5.58893 , y:198.87451)
 position : (x:-43.21261 , y:182.6366)
 position : (x:5.885054 , y:199.23691)
 position : (x:-42.86318 , y:182.91586)
 position : (x:6.4043913 , y:199.99516)
 position : (x:-42.419323 , y:180.8524)
 position : (x:6.086983 , y:199.51636)
 position : (x:-42.896065 , y:184.15248)

There is a bug or I don't understand why this information are changing ?

Edit :

There is a problem with FingerID, it's sound like two thumbs are detected in spit of the fact I control if it's the right hand :

frameID: 96859 FingerID: 410 position : (x:-63.791225 , y:171.73073)
frameID: 96859 FingerID: 411 position : (x:10.867295 , y:157.37088)
frameID: 96934 FingerID: 410 position : (x:-63.86908 , y:173.62065)
frameID: 96934 FingerID: 411 position : (x:10.567341 , y:157.86476)
Quentin T.
  • 267
  • 2
  • 8
  • 27
  • 1
    Add frame ID and finger ID to your print out to see if you are getting two right thumbs in a frame rather than one thumb jumping to two different positions in alternate frames. Also look at the diagnostic visualizer to see what it shows is happening. – Charles Ward Jan 16 '15 at 04:49
  • Nice idea, it's not the same fingerID : frameID: 38641 FingerID: 211 position : (x:47.511364 , y:194.00133) frameID: 38715 FingerID: 210 position : (x:-14.853537 , y:202.17497) It's like I have 2 thumbs but I always exclude one hands, how it's possible ? (And I have just 1 hand on the visualizer ...) – Quentin T. Jan 16 '15 at 14:33
  • Solved: problem with the switch case... Very strange. – Quentin T. Jan 16 '15 at 15:18

1 Answers1

1

There was a problem with the Switch Case... (I don't know exactly why) but the switch case + the f.hand().isRight() is not working properly.

switch (f.type()) 
{                
   case TYPE_THUMB : 
        if(f.hand().isRight())
        {
          ...
        }
}

My solution is to add a second verification :

switch (f.type()) 
{                
   case TYPE_THUMB :
      if(f.type().swigValue() == 0)
      { 
        if(f.hand().isRight())
        {
          ...
        }
      }
}
Quentin T.
  • 267
  • 2
  • 8
  • 27
  • 1
    Your trace output shows that the two fingers are on the same hand. The last digit of the finger id is 0-5 for thumb-pinky. The previous digits are the hand ID. So the second finger is an index finger. It still doesn't make sense that it gets printed by the Thumb case statement, though. In fact, I copied your original code into a Processing sketch and it works fine (only prints right thumb information). – Charles Ward Jan 16 '15 at 18:56
  • I don't understand why my switch case doesn't works in my code, but np I've solve the problem. Thanks for help. – Quentin T. Jan 16 '15 at 23:33