我正在为Leap开发一个自定义手势创建应用程序(Java语言)。在onFrame函数中,代码执行到一定程度后,其余的代码将被跳过。
以下是onFrame函数的代码:
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...");
}
}
一切都很顺利,直到调用“recordFrame(frame)”函数。在此函数后的任何代码都被忽略/未执行。我似乎跳过了代码,而不是跳过帧。
recordFrame的代码如下:
/**
* 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...");
}