2015-04-02 62 views
1

我正在使用來自kinect for Windows SDK示例的FaceTracking應用程序。 我已經讀過頭部姿勢角度將有助於檢測頭部運動(頭部點頭或頭部晃動)。 在這一刻,我有頭部姿態角度的價值。 我的問題是如何計算頭部姿勢角度的差異? 我知道我需要以前的幀的值。 我真的不知道如何存儲以前的幀的值,並將其用於進一步的分析。 有沒有人有關於這個主題的想法? 期待您的建議。如何計算兩個相鄰幀中的俯仰和偏航角差

非常感謝你提前。

編輯:我試過一種方法來存儲以前的幀和顯示角度之間的差異。但我的幀沒有更新,我沒有得到預期的角度差異。我從以下代碼獲取了面向應用程序的代碼。有人能告訴我我在哪裏做錯了嗎?

internal void OnFrameReady(KinectSensor kinectSensor, ColorImageFormat colorImageFormat, byte[] colorImage, DepthImageFormat depthImageFormat, short[] depthImage, Skeleton skeletonOfInterest) 
     { 
      this.skeletonTrackingState = skeletonOfInterest.TrackingState; 

      if (this.skeletonTrackingState != SkeletonTrackingState.Tracked) 
      { 
       // nothing to do with an untracked skeleton. 
       return; 
      } 

      if (this.faceTracker == null) 
      { 
       try 
       { 
        this.faceTracker = new FaceTracker(kinectSensor); 
       } 
       catch (InvalidOperationException) 
       { 
        // During some shutdown scenarios the FaceTracker 
        // is unable to be instantiated. Catch that exception 
        // and don't track a face. 
        Debug.WriteLine("AllFramesReady - creating a new FaceTracker threw an InvalidOperationException"); 
        this.faceTracker = null; 
       } 
      } 

      if (this.faceTracker != null) 
      { 
      FaceTrackFrame frame = this.faceTracker.Track(
        colorImageFormat, colorImage, depthImageFormat, depthImage, skeletonOfInterest); 
       this.lastFaceTrackSucceeded = frame.TrackSuccessful; 

       if (this.lastFaceTrackSucceeded) 
       { 
       /* 
        pitch = frame.Rotation.X; 
       yaw = frame.Rotation.Y; 
        roll = frame.Rotation.Z;*/ 
        Vector3DF faceRotation = frame.Rotation; 
        pose = string.Format("Pitch:\t{0:+00;-00}°\nYaw:\t{1:+00;-00}°\nRoll:\t{2:+00;-00}°", faceRotation.X, faceRotation.Y, faceRotation.Z); 
        if (oldFrame != null) 
        { 
         Vector3DF faceRotation1 = oldFrame.Rotation; 
         difference = string.Format("Pitch:\t{0:+00;-00}°\nYaw:\t{1:+00;-00}°\nRoll:\t{2:+00;-00}°", faceRotation.X - faceRotation1.X, faceRotation.Y - faceRotation1.Y, faceRotation.Z-faceRotation1.Z); 
        } 
        if (faceTriangles == null) 
        { 
         // only need to get this once. It doesn't change. 
         faceTriangles = frame.GetTriangles(); 
        } 

        this.facePoints = frame.GetProjected3DShape(); 
        } 

      } 
      oldFrame = frame; // FaceTrackFrame oldFrame; 

     } 
+0

請找我編輯的問題。 – user3792685 2015-04-07 15:09:34

回答

1

我已經做了下面的行chnages複製當前幀到其他幀對象。 我已經使用了克隆方法。

oldFrame = (FaceTrackFrame)frame.Clone(); 

現在它給我正確的差異