• 【Unity/Kinect】使用KinectManager的一般流程


    想要从Kinect读取到数据,然后使用数据,通常是以下流程:

    using UnityEngine;
    using System.Collections;
    
    /// <summary>
    /// 使用KinectManager的一般流程。
    /// </summary>
    public class UseKinectManager : MonoBehaviour {
    
        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)) {
                        // 获取目标关节点在Kinect坐标系的位置
                        Vector3 leftHandPos = _manager.GetJointKinectPosition(userId, jointIndex);
                        // todo:其他逻辑
                        // ...
                        Debug.Log(leftHandPos);
                        // ...
                    }
                }
            }
        }
    }
    
  • 相关阅读:
    Python学习笔记Day08
    Python学习笔记Day06~07
    Python学习笔记Day05
    linux文件属性之用户和组基础知识
    linux文件属性之linux文件删除原理
    linux文件属性软硬链接知识
    linux文件属性文文件类型知识
    linux文件属性描述(inode,block)
    xargs命令
    find命令
  • 原文地址:https://www.cnblogs.com/guxin/p/unity-kinect-how-to-use-kinectmanager.html
Copyright © 2020-2023  润新知