Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Kinect v2跟踪个人信息_C#_Visual Studio_Kinect_Gesture - Fatal编程技术网

C# Kinect v2跟踪个人信息

C# Kinect v2跟踪个人信息,c#,visual-studio,kinect,gesture,C#,Visual Studio,Kinect,Gesture,我想弄清楚如何区分使用Kinect 2跟踪的两个人。所以,如果玩家一做了这个手势,就执行这个动作。如果玩家2做了这个手势,执行这个动作。我正在尝试使用跟踪ID,但我不确定是否正确。以下是我的一些代码片段: /// <summary> /// Gets or sets the body tracking ID associated with the current detector /// The tracking ID can change whenever a bo

我想弄清楚如何区分使用Kinect 2跟踪的两个人。所以,如果玩家一做了这个手势,就执行这个动作。如果玩家2做了这个手势,执行这个动作。我正在尝试使用跟踪ID,但我不确定是否正确。以下是我的一些代码片段:

/// <summary>
    /// Gets or sets the body tracking ID associated with the current detector
    /// The tracking ID can change whenever a body comes in/out of scope
    /// </summary>
    public ulong TrackingId
    {
        get
        {

            return this.vgbFrameSource.TrackingId;
        }

        set
        {

            Debug.WriteLine(value);
            if (this.vgbFrameSource.TrackingId != value)
            {
                this.vgbFrameSource.TrackingId = value;
                if (value == 0)
                {
                    outOfFrame = 0;
                    this.vgbFrameSource.TrackingIdLost += this.Source_TrackingIdLost;
                }
                else if (one == 0 )
                {
                    playerOne = value;
                    ++one;
                    ++outOfFrame;
                }
                else if (two == 0 && value != playerOne)
                {
                    playerTwo = value;
                    ++two;
                    ++outOfFrame;
                }

                Debug.WriteLine(outOfFrame);
            }
        }
    }
这就是我发送数据的地方

这是建立在微软的源代码基础上的离散手势检测器


编辑:找到问题。播放器1的跟踪ID被多次重置,因此它永远不会进入TrackingId中的最后一个if语句。现在只需要弄清楚那里发生了什么。

用getter和setter解决了问题,因为值1和跟踪id被重置

if (outOfFrame == 0)
{
     Debug.WriteLine("No Players in Frame");
}
else if (result.Detected && this.vgbFrameSource.TrackingId == playerOne && outOfFrame != 0)
{
      //nameGest = gestureName;
      //Debug.WriteLine(gestureName);
      Player1.AbstractState.setGestureName((string)gestureName);
      //Player1.AbstractState.setDetector(this);
}

else if (result.Detected && this.vgbFrameSource.TrackingId != playerOne && outOfFrame != 0)
{
      //nameGest = gestureName;
      //Player2.AbstractState.setGestureName(gestureName);
      Player2.AbstractState.setGestureName((string)gestureName);
      //Player2.AbstractState.setDetector(this);
}