如何计算相邻两帧的俯仰角和偏航角之差

How to calculate the difference of pitch and yaw anlges in two adjacent frames

我正在为 Windows SDK 示例使用来自 kinect 的 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;

        }

我对以下行进行了更改,以将当前 Frame 复制到其他 Frame 对象。 我已经使用了克隆方法。

 oldFrame = (FaceTrackFrame)frame.Clone();

现在它给了我正确的区别