Kinect v2.0 FaceFrameResult.FaceRotationQuaternion返回NAN

时间:2016-05-20 14:44:37

标签: kinect kinect-sdk

使用kinect我试图获得人脸的偏航俯仰和滚动。 为了计算这些值,我试图获得FaceRotationQuaternion。然而,它似乎返回NaN的Y和Z值。

旋转四元数值的示例:

X: 0 Y: NaN Z: NaN W: 2.80259692864963E-45

用于新面部框架到达时的代码。

    void FaceReader_FrameArrived(object sender, FaceFrameArrivedEventArgs e)
    {
        using (var frame = e.FrameReference.AcquireFrame())
        {
            if (frame != null)
            {
                // 4) Get the face frame result
                FaceFrameResult result = frame.FaceFrameResult;

                if (result != null)
                {
                    System.Diagnostics.Debug.WriteLine("Found Face");

                    faceRotation = result.FaceRotationQuaternion;
                    double x = result.FaceRotationQuaternion.X;
                    double y = result.FaceRotationQuaternion.Y;
                    double z = result.FaceRotationQuaternion.Z;
                    double w = result.FaceRotationQuaternion.W;

                    System.Diagnostics.Debug.WriteLine("X: " + x + " Y: " + y + " Z: " + z + " W: " + w);

                }
             }
         }
     }

脸部已在身体上注册。

  void BodyReader_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {

            //Sent the data over bluetooth.
            //btc.sendKinectData(kinectData);

            using (var frame = e.FrameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    bodies = new Body[frame.BodyFrameSource.BodyCount];
                    frame.GetAndRefreshBodyData(bodies);

                    Body body = bodies.Where(b => b.IsTracked).FirstOrDefault();

                    if (!faceFrameSource.IsTrackingIdValid)
                    {
                        if (body != null)
                        {
                            // 4) Assign a tracking ID to the face source
                            faceFrameSource.TrackingId = body.TrackingId;
                        }
                    }
                }
            }
        }

如何使用FaceRotationQuaternion获取正确的值?

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。看起来头部的方向也是一个特征,因此它需要在它工作之前加载。

faceFrameSource = new FaceFrameSource(kinectSensor,0,FaceFrameFeatures.RotationOrientation);