Reputation: 31
I am developing a custom gesture creation application for Leap in Java. In the onFrame function code is being executed up to a point and the rest of the code is skipped.
The code for onFrame is below:
public void onFrame(Controller controller) {
Frame frame = controller.frame();
if (recordableFrame(frame, minRecordingVelocity)){
/*
* If this is the first frame in a gesture, we clean up some running values
*/
if (!recording) {
recording = true;
frameCount = 0;
}
frameCount++;
System.out.println("in frame... " + Integer.toString(frameCount));
recordFrame(frame);
System.out.println("Recording Frame...");
}
}
Everything works fine, until the "recordFrame(frame) function is called. This function and any code in onFrame after this function is ignored/not executed. Instead of skipping frames, I seem to be skipping code.
The code for recordFrame is below:
/**
* This function is called for each frame during gesture recording,
* and it is responsible for adding values in frames using the provided
* recordPoint function (which accepts a Vector).
*/
public void recordFrame(Frame frame) {
HandList hands = frame.hands();
int handCount = hands.count();
Hand hand;
Finger finger;
FingerList fingers;
int fingerCount;
int l = handCount;
for (int i = 0; i < l; i++) { //for each hand in the frame
hand = hands.get(i);
recordPoint(hand.stabilizedPalmPosition()); //record the palm position
fingers = hand.fingers();
fingerCount = fingers.count();
int k = fingerCount;
for (int j = 0; j < k; j++) { //for each finger in the hand
finger = fingers.get(j);
recordPoint(finger.stabilizedTipPosition();//record fingertip position.
}
}
System.out.println("Recording Frame...");
}
Upvotes: 3
Views: 166
Reputation: 1388
From Leap Motion forum:
"I found the issue. In the gesture class I declare ArrayList but never initialize it with = new ArrayList(); (weird that it didn't throw a compiler error)
Once I did that everything worked fine. I've now got it working and running."
https://community.leapmotion.com/t/listener-onframe-is-skipping-code/3108/7
Upvotes: 1