zoukankan      html  css  js  c++  java
  • 【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手势";
                        }
                    }
                }
            }
        }
    }
    
  • 相关阅读:
    INI配置文件的格式
    MFC的DLL中实现定时器功能
    三维数组的动态申请与释放
    bat批处理,实现获取目录
    windows 系统变量
    php分享二十一:mysql语句
    php分享二十:mysql优化
    php分享十九:网络带宽预估
    php分享十七:http状态码
    从“什么是程序化购买”到“程序化购买+”
  • 原文地址:https://www.cnblogs.com/guxin/p/unity-kinect-how-to-use-hand-state.html
Copyright © 2011-2022 走看看