Hi, im trying to use "Transforming Finger Coordinates into the Hand’s Frame of Reference" without success.
[Developer Documentation for HFoF transform]
I'm trying to use it to then get the coordinates data of the fingers with respect to the position of the palm.
I am quite new to Java and apparently I am using the indications badly, but I can not carry it out, maybe because of the location of some line of code or maybe by mistake in the name of variables. I really do not know, please help me.
Here is my code...
Really thanks!
@Override
public void onFrame(Controller controller) {
// Get the most recent frame and report some basic information
Frame frame = controller.frame();
System.out.println("Frame id: " + frame.id());
//Get hands
for(Hand hand : frame.hands()) {
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SS");
String currentTime = dateFormat.format(System.currentTimeMillis());
String handType = hand.isLeft() ? "Mano izquierda" : "Mano derecha";
//ToBasis
for(int h = 0; h < frame.hands().count(); h++){
Hand leapHand = frame.hands().get(h);
Vector handXBasis = leapHand.palmNormal().cross(leapHand.direction()).normalized();
Vector handYBasis = leapHand.palmNormal().opposite();
Vector handZBasis = leapHand.direction().opposite();
Vector handOrigin = leapHand.palmPosition();
Matrix handTransform = new Matrix(handXBasis, handYBasis, handZBasis, handOrigin);
handTransform = handTransform.rigidInverse();
for( int f = 0; f < leapHand.fingers().count(); f++ ){
Finger leapFinger = leapHand.fingers().get(f);
Vector transformedPosition = handTransform.transformPoint(leapFinger.tipPosition());
Vector transformedDirection = handTransform.transformDirection(leapFinger.direction());
// Do something with the transformed fingers
WTF
}
}
System.out.println(" " + handType
+ ", Posicion palma: " + hand.palmPosition());
// Get fingers
for (Finger finger : hand.fingers()) {
System.out.println(" " + finger.type() + ", id: " + finger.id()
+ ", longitud: " + finger.length()
+ "mm, ancho: " + finger.width() + "mm");
//Get Bones
for(Bone.Type boneType : Bone.Type.values()) {
Bone bone = finger.bone(boneType);
System.out.append(" " + bone.type()
+ " Centro Hueso: " + bone.center());
}
}