I am creating a program where you do rep of a stretch, so it adds one to amount of reps. I want to have a interval between each rep (not the current problem). I have this nested within the AllFramesReadyEventArgs. The problem is, since the SDK uses the AllFramesReadyEvent through out the whole program, so it is an infinite loop. How can I do each rep without it repeating when I don’t want it to? Thanks in advance.
if (skeleton.TrackingState == SkeletonTrackingState.Tracked)
{
int whereIsX = (int)Canvas.GetLeft(ellipse1);
int whereToX = (int)Canvas.GetLeft(pspine);
whatToMultiplyX = whereToX / whereIsX;
int whereIsY = (int)Canvas.GetTop(ellipse1);
int whereToY = (int)Canvas.GetTop(pspine);
whatToMultiplyY = whereToY / whereIsY;
Canvas.SetTop(ellipse1, Canvas.GetTop(ellipse1) * whatToMultiplyY);
Canvas.SetLeft(ellipse1, Canvas.GetLeft(ellipse1) * whatToMultiplyX);
for (int i = 0; i < Doctor_ShoulderX.Count; i++)
{
Canvas.SetTop(doctorHand, Doctor_HandY[i] * whatToMultiplyY);
Canvas.SetTop(doctorElbow, Doctor_ElbowY[i] * whatToMultiplyY);
Canvas.SetTop(doctor_Shoulder, Doctor_ShoulderY[i] * whatToMultiplyY);
Canvas.SetLeft(doctorHand, Doctor_HandX[i] * whatToMultiplyX);
Canvas.SetLeft(doctorElbow, Doctor_ElbowX[i] * whatToMultiplyX);
Canvas.SetLeft(doctor_Shoulder, Doctor_ShoulderX[i] * whatToMultiplyX);
handX = Canvas.GetLeft(handright);
handY = Canvas.GetTop(handright);
elbowX = Canvas.GetLeft(elbowright);
elbowY = Canvas.GetTop(elbowright);
shoulderX = Canvas.GetLeft(shoulderright);
shoulderY = Canvas.GetTop(shoulderright);
shoulder_x.Text = "Shoulder X: " + shoulderX.ToString();
shoulder_y.Text = "Shoulder Y: " + shoulderY.ToString();
elbow_x.Text = "Elbow X: " + elbowX.ToString();
elbow_y.Text = "Elbow Y: " + elbowY.ToString();
hand_x.Text = "Hand X: " + handX.ToString();
hand_y.Text = "Hand Y: " + handY.ToString();
Patient_HandX.Add(handX);
Patient_HandY.Add(handY);
Patient_ElbowX.Add(elbowX);
Patient_ElbowY.Add(elbowY);
Patient_ShoulderX.Add(shoulderX);
Patient_ShoulderY.Add(shoulderY);
}
}
I’ll use answer cause more writing than comment can handle 🙂
aleframesready action is invoked in every frame. so if here you have limit of 20 in loop
it will be invoked from 0 to 20 every time. Imo you you should create a static boolean variable in the class. After the code go out from the loop set it to false (if on start it had true). Before you invoke the loop check if the variable is set to true. If yes invoke the loop, if no just continue