(三)Kinect姿势识别

Kinect给我们内置了许多姿势如举手等,具体可参考枚举KinectGestures.Gestures,也可以通过Kinect姿势管理器,自定义姿势导入(坑较多,内置的基本够用了)也可以根据关节坐标自己程序定义姿势。本节主要讲解内置姿势使用。

此部分可参考插件场景KinectGesturesDemo1和KinectGesturesDemo2,使用内置姿势只需要在自己的脚本中实现接口ModelGestureListener : MonoBehaviour, KinectGestures.GestureListenerInterface即可。参考脚本ModelGestureListener和CubeGestureListener

接口方法:

1)public void UserDetected(long userId, int userIndex)

通过此方法来注册检测的姿势,即对要检测的姿势进行定义

2)public void UserLost(long userId, int userIndex)

UserDetected中通过userIndex定义的用户丢失时执行此方法

3)public void GestureInProgress(long userId, int userIndex, KinectGestures.Gestures gesture,
                                  float progress, KinectInterop.JointType joint, Vector3 screenPos)

姿势进行时激发方法

4)public bool GestureCompleted (long userId, int userIndex, KinectGestures.Gestures gesture,
                                  KinectInterop.JointType joint, Vector3 screenPos)

当姿势完成时激活此方法

5)public bool GestureCancelled (long userId, int userIndex, KinectGestures.Gestures gesture,
                                  KinectInterop.JointType joint)
当取消时激活此方法

 

注:通过代码自定义姿势时可以采用获取到的关节点screenPos来进行匹配,也可以通过joint来获取joint实际位置进行判断

 

posted @ 2018-05-01 17:05  81192  阅读(2947)  评论(2编辑  收藏  举报