private void Timer_Tick(Object sender, EventArgs e) //timer for continuous check { if (currentFrame != null) { double[] velocityArr = LeapEventListener.getVelocity(currentFrame); ts++; if (velocityArr[0] < Constants.velocityThreshold && velocityArr[1] < Constants.velocityThreshold && velocityArr[2] < Constants.velocityThreshold && velocityArr[3] < Constants.velocityThreshold && velocityArr[4] < Constants.velocityThreshold) { if (LeapEventListener.isZeros(velocityArr) == false) { /* * if (ts - timeStamp > Constants.positionStallThreshold / 10) * { * tempFrame = currentFrame; * timeStamp = ts; * TranslateInstance(tempFrame); * * } */ if (toExtract == false) // if the letter is not ready for extraction { tempFrame = currentFrame; timeStamp = ts; toExtract = true; printPermission = true; // gives permission for the letter to be printed, prevent duplicates } if (ts - timeStamp > (Constants.positionStallThreshold / 10) / 2) //check if the user stayed in the same position 1 sec { tempFrame = currentFrame; } if (ts - timeStamp > Constants.positionStallThreshold / 10 && toExtract == true && printPermission == true) //check if the user stayed in the same position 1 sec { printPermission = false; TranslateInstance(tempFrame); timeStamp = 0; ts = 0; } } } else//user switch to the next letter { toExtract = false; printPermission = false; // timeStamp = ts; // sahar } } }
void frameListener(Frame frame) // the frame handler { currentFrame = frame; double[] distances = new double[5]; i++; if (i == Constants.framesInterval) { distances = LeapEventListener.getVelocity(frame); OutputData1.Text = distances[0].ToString(); OutputData2.Text = distances[1].ToString(); OutputData3.Text = distances[2].ToString(); OutputData4.Text = distances[3].ToString(); OutputData5.Text = distances[4].ToString(); i = 0; } }