0

我正在创建一个程序,您可以在其中进行一次伸展运动,因此它会增加一个次数。我想在每个代表之间有一个间隔(不是当前问题)。我有这个嵌套在AllFramesReadyEventArgs. 问题是,由于SDK使用了AllFramesReadyEvent整个程序,所以它是一个无限循环。当我不想重复时,我怎样才能在不重复的情况下完成每个重复?提前致谢。

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);
    }
}
4

1 回答 1

1

我将使用答案,因为写作比评论可以处理的更多:)

aleframesready 动作在每一帧中被调用。所以如果在这里你的循环限制为 20

for (int i = 0; i < Doctor_ShoulderX.Count; i++)

每次都会从 0 到 20 调用它。Imo 你应该在类中创建一个静态布尔变量。代码从循环中退出后,将其设置为 false(如果在开始时为 true)。在调用循环之前,请检查变量是否设置为 true。如果是,则调用循环,如果不是,则继续

于 2012-07-09T14:22:10.437 回答