zoukankan      html  css  js  c++  java
  • (一) kinect概述

    Kinect可以进行身体节点定位,姿势定位,人脸识别等功能,在此先做简单介绍,后续主要介绍插件的应用,毕竟自己开发识别过程太消耗时间。

    (注1:Kinect官方虽然提供了Unity的APi,但是方便起见采用一些插件,更利于开发相关功能。采用插件有Kinect+for+unity+sdk+v2.9.unitypackage    和Kinect+v2+Examples+with+MS-SDK+.unitypackage,其实这两个是一样的)

    1)新建一个空游戏物体,添加KinectManager组件

    2)新建脚本,通过kinectManger = KinectManager.Instance;获取到KinectManager运行实例。

    3)通过kinectManger 即可获取Kinect识别的人物位置,关节等,如下简单代码所示:

    注1:一下都是简单代码,应用时主要采用插件中已经给定的脚本,功能很完善,一下简单代码只是为了理解,可掠过)

    注2:Kinect识别任务施工过userID(long类型)来识别,此Id通过一个传入的int 类型的参数(表示第几个body)获得)

        /// <summary>
        /// 获取kinect摄像头画面,KinectManager中Computer color Map需勾选
        /// 如果勾选Display color map则会自动显示,并可通过Display maps by percent 修改画面大小
        /// </summary>
        private void GetKinectTexture()
        {
            Texture kinectTexture = kinectManger.GetUsersClrTex();
            disRawImage.texture = kinectTexture;
        }
        /// <summary>
        /// kinectManger初始化后是否检测到人体
        /// </summary>
        /// <returns></returns>
        private bool GetDetected()
        {
            //return kinectManger != null && kinectManger.IsInitialized() && kinectManger.GetUsersCount() > 0;
            return kinectManger.IsUserDetected();
        }
       /// <summary>
        /// 人体检测,获取人体的body位置
        /// 获取到的bodyPostion是根据Kinect的实际高度等参数获得的真是距离,单位为M。
        /// 如果获取到的数据要反馈到UI上则需要按分辨率进行折算
        /// 如果bodyGo尺寸较大,但是获取到的bodyPostion的移动数据较小,则移动效果不明显
        /// </summary>
        /// <param name="index">获取第几个人体数据</param>
        private void GetUserBody(int index)
        {
            //if(kinectManger!=null && kinectManger.IsInitialized())
            //{
            //    long userId = kinectManger.GetUserIdByIndex(index);
            //    Vector3 bodyPostion = kinectManger.GetUserPosition(userId);
            //    bodyGo.transform.position = bodyPostion;
            //}
    
            if (GetDetected())
            {
                long userId = kinectManger.GetUserIdByIndex(index);
                Vector3 bodyPostion = kinectManger.GetUserPosition(userId);
                bodyGo.transform.position = bodyPostion;
                print("body position:" + bodyPostion);
            }
        }
  • 相关阅读:
    Ant利用第三方的task
    读《NoSQL精粹》前三章有感
    opensuse12.3 桌面设置备忘录
    clojure中符号symbols 和变量vars的正确理解
    vim配置clojure开发环境备忘录
    移动端调试痛点?——送你五款前端开发利器
    SyntaxError: missing ) after argument list
    铺满屏幕的布局方法
    剖析height百分比和min-height百分比
    父元素高度设置为min-height,子元素高度设置为100%,但实际上子元素高度你知道是多少吗?(2019-10-26更新)
  • 原文地址:https://www.cnblogs.com/llstart-new0201/p/8976394.html
Copyright © 2011-2022 走看看