【Unity/Kinect】获取预制的手势信息KinectInterop.HandState

Kinect使用了枚举KinectInterop.HandState来描述手势。 该手势指的是手掌的状态(张开/握拳),而不是说整个手臂的肢体动作(Gesture)。
同样是需要嵌套在Kinect获取数据的代码块中,然后添加自己的逻辑。

http://blog.csdn.net/qq_18995513/article/details/53180695

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

/// <summary>
/// 使用KinectManager的一般流程。
/// </summary>
public class UseKinectManager : MonoBehaviour {

    public Text debugText;  // 显示当前的手势
    KinectManager _manager;

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {

        if (_manager == null) {
            _manager = KinectManager.Instance;
        }

        // 是否初始化完成
        if (_manager && _manager.IsInitialized()) { 
            // 是否人物被检测到
            if (_manager.IsUserDetected()) {
                // 获取用户ID
                long userId = _manager.GetPrimaryUserID();
                // 获取目标关节点的索引(以左手为例)
                int jointIndex = (int)KinectInterop.JointType.HandLeft;
                // 判断目标关节点是否被追踪
                if (_manager.IsJointTracked(userId, jointIndex)) {
                    // 检测手势信息
                    KinectInterop.HandState leftHandState = _manager.GetLeftHandState(userId);
                    if (leftHandState == KinectInterop.HandState.Closed)
                    {
                        debugText.text = "左手握拳";
                    }
                    else if (leftHandState == KinectInterop.HandState.Open)
                    {
                        debugText.text = "左手展开";
                    }
                    else if (leftHandState == KinectInterop.HandState.Lasso)
                    {
                        debugText.text = "左手yes手势";
                    }
                }
            }
        }
    }
}
原文地址:https://www.cnblogs.com/guxin/p/unity-kinect-how-to-use-hand-state.html