我正在为Leap in 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)函数被调用。此函数和onFrame中的任何代码都被忽略/不执行。而不是跳帧,我似乎是在跳过代码。
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...");
}
答案 0 :(得分:1)
来自Leap Motion论坛:
&#34;我发现了这个问题。在gesture类中,我声明了ArrayList,但从未使用= new ArrayList()初始化它; (奇怪的是,它没有抛出编译器错误)
一旦我这样做,一切正常。我现在已经开始工作了。&#34;
https://community.leapmotion.com/t/listener-onframe-is-skipping-code/3108/7