0

Kinect の位置を記録するときに、ストップウォッチの開始と停止を試みています。

   //process x and y coordinates
   public void calculateJoints(Skeleton skeleton)
    {          
        Joint rightHand = skeleton.Joints[JointType.HandRight];
        Joint leftHand = skeleton.Joints[JointType.HandRight];
        rightX = rightHand.Position.X;
        rightY = rightHand.Position.Y;         

    }

//start the stopwatch (tried to use a greater time between positions 1 and 5 vs 1 and 2
  public void processJointsAndRepeat(Skeleton skeleton)
  {
        startTime();
        while (numPositions < 5)
        {   
             calculateJoints(skeleton);
             numPositions++;
        }
        stopTime();
        double tempTime = calculateTimeElapsed();
  }

   //calculate time in milliseconds
   private double calculateTimeElapsed()
    {
        long milliseconds = stopWatch.ElapsedMilliseconds;
        return (double)milliseconds;
    }

しかし、時間をキーとして x、y、および時間の値を入力しようとすると、キーが重複しているというエラーがスローされます。tempTime の値を取得すると、0 しか表示されませんでした。

これは私のコードの問題ですか、それとももっと正確なストップウォッチが必要ですか?

30 fps の時間を確保するのは難しいと認識しているので、他に提案があれば、それは素晴らしいことです! 私は基本的に、ポイント間の平均速度を計算して、オーディオ ファイルの再生速度を調整しようとしています。ありがとう!

4

1 に答える 1

1

ストップウォッチは、通常の Windows ボックスで最高の解像度を持つタイマーのラッパーです。Stopwatch.ElapsedTicksStopwatch.Frequencyを使用して、あまり派手でない関数を使用して MS 解像度よりも高くすることができます。

あなたの問題はおそらくタイマーに関連しているのではなく、表示されていない他のコードに関連していることに注意してください...

于 2013-03-12T00:37:16.387 に答える