我正在使用kinect的FaceTracking应用程序来获取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 :(得分:1)
我对以下行进行了更改,将当前Frame复制到其他Frame对象。 我使用了克隆方法。
oldFrame = (FaceTrackFrame)frame.Clone();
现在它给了我正确的差异