I'm inexperienced in java, at this moment I can only see the data of hand.palmPosition () in my .txt, but I need to get bone.center () on all the iterations
I try with:
out.println (hand.finger (fingerID) .bone (Bone.Type.TYPE_DISTAL) .center ());
//cant take the current finger.id, then i just use the previous who i get on another run of the program, like 2035 or something
without success, it only showed "INVALID BONE" in the .txt file
Please help!
This is all the code
@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";
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());
}
}
//.txt
File datos = new File("Data.txt");
try(FileWriter fw = new FileWriter(datos, true);
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter out = new PrintWriter(bw))
{
out.println(currentTime);
out.println(frame.id());
out.println(hand.palmPosition().getX());
out.println(hand.palmPosition().getY());
out.println(hand.palmPosition().getZ());
out.println(hand.frame().currentFramesPerSecond());
out.println(hand.finger(2850).bone(Bone.Type.TYPE_DISTAL).center());
} catch (IOException e){
e.printStackTrace();
}
}
if (!frame.hands().isEmpty()) {
System.out.println();
}
}