|
|
@ -9,7 +9,7 @@ using Microsoft.Kinect;
|
|
|
|
|
|
|
|
|
|
|
|
namespace KinectUtils
|
|
|
|
namespace KinectUtils
|
|
|
|
{
|
|
|
|
{
|
|
|
|
static class GestureManager
|
|
|
|
public static class GestureManager
|
|
|
|
{
|
|
|
|
{
|
|
|
|
static private BodyFrameReader bodyFrameReader;
|
|
|
|
static private BodyFrameReader bodyFrameReader;
|
|
|
|
static private Body[] bodies;
|
|
|
|
static private Body[] bodies;
|
|
|
@ -17,24 +17,31 @@ namespace KinectUtils
|
|
|
|
static KinectManager KinectManager { get; set; }
|
|
|
|
static KinectManager KinectManager { get; set; }
|
|
|
|
static List<BaseGesture> KnownGestures { get; set; }
|
|
|
|
static List<BaseGesture> KnownGestures { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
static public void AddGestures(IGestureFactory factory)
|
|
|
|
public static void AddGestures(IGestureFactory factory)
|
|
|
|
{
|
|
|
|
|
|
|
|
KnownGestures = (List<BaseGesture>)factory.CreateGestures();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static public void AddGestures(params BaseGesture[] gestures)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
var gestures = factory.CreateGestures();
|
|
|
|
foreach (var gesture in gestures)
|
|
|
|
foreach (var gesture in gestures)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!gestures.Contains(gesture))
|
|
|
|
AddGesture(gesture);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void AddGesture(BaseGesture gesture)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!KnownGestures.Contains(gesture))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
KnownGestures.Add(gesture);
|
|
|
|
KnownGestures.Add(gesture);
|
|
|
|
|
|
|
|
gesture.GestureRecognized += (sender, e) => GestureRecognized?.Invoke(sender, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static void RemoveGesture(BaseGesture gesture)
|
|
|
|
static public void RemoveGesture(BaseGesture gesture)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (KnownGestures.Contains(gesture))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
KnownGestures.Remove(gesture);
|
|
|
|
KnownGestures.Remove(gesture);
|
|
|
|
|
|
|
|
gesture.GestureRecognized -= (sender, e) => GestureRecognized?.Invoke(sender, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static public void StartAcquiringFrames(KinectManager kinectManager)
|
|
|
|
static public void StartAcquiringFrames(KinectManager kinectManager)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bodyFrameReader = kinectManager.Sensor.BodyFrameSource.OpenReader();
|
|
|
|
bodyFrameReader = kinectManager.Sensor.BodyFrameSource.OpenReader();
|
|
|
|