Hi Guys,
I know this thread is a little old, but I just got a Leap Motion
Taking advantage of this thread on this topic, I would like to ask for help with Leap Motion in Java Processing to detect only the right hand independently of the left hand.
From the code below I can retrieve both hands only if the left was detected at first. I'd like to make the right one more autonomous.
Any help will be so appreciated. Thank you!
import com.leapmotion.leap.*;
Controller controller = new Controller();
void setup() {
size( displayWidth, displayHeight );
}
void draw() {
background(0);
InteractionBox iBox = controller.frame().interactionBox();
HandList hands = controller.frame().hands();
Hand leftHand = hands.get(0);
Arm leftArm = leftHand.arm();
Hand leftMost = hands.leftmost();
Hand rightHand = hands.get(1);
Arm rightArm = rightHand.arm();
Hand rightMost = hands.rightmost();
Vector filteredHandPositionL = leftHand.stabilizedPalmPosition();
Vector normalizedPointL = iBox.normalizePoint(filteredHandPositionL, true);
Vector filteredHandPositionR = rightHand.stabilizedPalmPosition();
Vector normalizedPointR = iBox.normalizePoint(filteredHandPositionR, true);
float leftX = normalizedPointL.getX() * width;
float leftY = (1 - normalizedPointL.getY()) * height;
float rightX = normalizedPointR.getX() * width;
float rightY = (1 - normalizedPointR.getY()) * height;
println(rightX, rightY);
if (rightMost.isRight()) {//secondHand.isRight()) {
fill(255, 0, 255);
ellipse(rightX, rightY, 45, 45);
}
pushMatrix();
if (leftHand.isLeft()) {
fill(255, 0, 0);
ellipse(leftX, leftY, 45, 45);
}
popMatrix();
}
Thank you guys for any help!
Cheers!