3

我正在尝试使用 Kinect 传感器和 SDK 来计算用户头部的方向,但我无法在谷歌上找到任何好的帮助。有没有人有任何好的样本、教程或类似的东西可以帮助我?

4

2 回答 2

2

我认为我已经找到了一个解决方案,虽然它是有限的,但它只有在 Kinect SDK 可以检测到面部时才有效,因为我正在使用该FaceTrackFrame对象。

如果有人在 Kinect SDK 无法检测到人脸时找到跟踪更极端角度的解决方案,我会更高兴看到它。

我的解决方案如下所示:

       FaceTrackFrame faceFrame = faceTracker.Track(
            kinectSensor.ColorStream.Format, colorPixelData,
            kinectSensor.DepthStream.Format, depthPixelData, skeleton);

        // Only works if face is detected
        if (faceFrame.TrackSuccessful)
        {
            txtTracked.Content = "TRACKED";
            txtRoll.Content = faceFrame.Rotation.Z;
            txtPitch.Content = faceFrame.Rotation.X;
            txtYaw.Content = faceFrame.Rotation.Y;
        }
于 2013-02-08T02:57:19.623 回答
1

我设法使用图像中的深度数据手动计算这些。

首先你需要得到深度点

    private EnumIndexableCollection<FeaturePoint, Vector3DF> depthPoints;

然后如果你看SDK自带的FaceTracking查看器代码,搜索DrawFaceModel函数。您可以在第一个 for 循环中提取这样的代码。

    faceModelPts3D.Add(new Point3D(this.depthPoints[i].X + 0.5f, this.depthPoints[i].Y + 0.5f, this.depthPoints[i].Z + 0.5f));
    FaceDataPoints.DepthXPointInfo[i] = this.depthPoints[i].X;
    FaceDataPoints.DepthYPointInfo[i] = this.depthPoints[i].Y;
    FaceDataPoints.DepthZPointInfo[i] = this.depthPoints[i].Z;

然后我将点 0 和点 9 放入以下函数中以获得音高。然后我将点 120 和 116 放入以获得打哈欠角度。

    public static double FacePitch(double FirstXPos, double FirstYPos, double FirstZPos, double SecXPos, double SecYPos, double SecZPos)
    {
        double PitchAngle = 0;
        double r = 0;
        double XDifference, YDifference, ZDifference = 0;
        double DifferenceSquared = 0;

        XDifference = FirstXPos - SecXPos;//Calculates distance from Points 
        YDifference = FirstYPos - SecYPos;
        ZDifference = FirstZPos - SecZPos;

        DifferenceSquared = Math.Pow(XDifference, 2) + Math.Pow(YDifference, 2) + Math.Pow(ZDifference, 2);

        r = Math.Sqrt(DifferenceSquared);

        PitchAngle = (Math.Acos(ZDifference / r));

        PitchAngle = ((PitchAngle * 180 / Math.PI) - 90) * -1; //Converts to Degrees as easier to recognise visually 

        return PitchAngle;
    }

对于滚动,我再次将点 0 和 9 放入并再次使用上述功能但我改变了

PitchAngle = (Math.Acos(ZDifference / r));

RollAngle = Math.Acos(XDifference / r);
于 2013-02-05T23:46:49.980 回答