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手势";
                        }
                    }
                }
            }
        }
    }
    
  • 相关阅读:
    高可用-mysql安装,双主模式+keepalived
    源码-mybatis-01-SqlSessionFactory创建
    J.U.C-volatile
    设计模式-模板设计模式(行为)
    设计模式-代理模式
    线程-join();
    Net Core 文件的上传下载
    mysql 开启日志记录执行SQL语句
    C# 方法多个返回值
    C# get set 方法 设置默认值
  • 原文地址:https://www.cnblogs.com/guxin/p/unity-kinect-how-to-use-hand-state.html
Copyright © 2011-2022 走看看