kinect笔记 二、识别手势(全身/姿势)

在unity中使用kinect识别手势等,我在这里用的是卡耐基梅隆的插件

网址  https://pan.baidu.com/s/19XbE7CLA64c1K6jrK9wf9g  密码 e4uw  或  链接:https://pan.baidu.com/s/10hC2mubXOrlpm6FD0ZjF4A 密码:odei

借鉴  https://www.cnblogs.com/Zackzhang/p/6203379.html

在场景中创建一个空物体,命名为KinectManager,给这个物体绑定上 KinectManager 和 KinectGestures脚本

再新建一个空物体,命名为MyGestureListener,新建一个脚本MyGestureListener.cs。这个脚本需要继承MonoBehaviour类并且实现KinectGestures.GestureListenerInterface接口。

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

public class MyGestureListener : MonoBehaviour,KinectGestures.GestureListenerInterface {

    [Tooltip("由该组件跟踪的播放器索引。0代表第一人,1人,第二人,2人,第三人,等等。")]
    public int playerIndex = 0;

    [Tooltip("Text 用于显示监听到的手势动作的信息")]
    public Text gestureInfo;

    //跟踪进程消息是否已显示的内部变量
    private bool progressDisplayed;
    private float progressGestureTime;

    //是否检测到需要的手势
    private bool swipeLeft;
    private bool swipeRight;
    private bool swipeUp;

    /// <summary>
    /// UDP客户端
    /// </summary>
    public UDPClient udpClient;

    /// <summary>
    /// 当检测到新用户时调用。在这里,可以通过调用KinectManager.DetectGesture()来开始手势跟踪。
    /// </summary>
    /// <param name="userId">User ID</param>
    /// <param name="userIndex">User index</param>
    public void UserDetected(long userId, int userIndex)
    {
        // 只允许主要用户使用手势
        KinectManager manager = KinectManager.Instance;
        if (!manager || (userIndex != playerIndex))
            return;

        // 检测这些用户特定的手势
        manager.DetectGesture(userId, KinectGestures.Gestures.SwipeLeft);
        manager.DetectGesture(userId, KinectGestures.Gestures.SwipeRight);
        manager.DetectGesture(userId, KinectGestures.Gestures.SwipeUp);

        /*manager.DetectG
  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值