|
|
@ -1,4 +1,5 @@
|
|
|
|
using KinectConnection;
|
|
|
|
using KinectConnection;
|
|
|
|
|
|
|
|
using Microsoft.Kinect;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
@ -7,13 +8,16 @@ using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace KinectUtils
|
|
|
|
namespace KinectUtils
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// static ?
|
|
|
|
|
|
|
|
public class GestureManager
|
|
|
|
public class GestureManager
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static bool isAcquiringFrame;
|
|
|
|
|
|
|
|
private static BodyFrameReader bodyFrameReader;
|
|
|
|
|
|
|
|
|
|
|
|
// Properties
|
|
|
|
// Properties
|
|
|
|
public static KinectManager KinectManager { get; set; } = new KinectManager();
|
|
|
|
public static KinectManager KinectManager { get; set; } = new KinectManager();
|
|
|
|
|
|
|
|
|
|
|
|
public static IEnumerable<BaseGesture> KnownGestures { get; private set; } = new List<BaseGesture>();
|
|
|
|
public static List<BaseGesture> KnownGestures { get; private set; } = new List<BaseGesture>();
|
|
|
|
|
|
|
|
|
|
|
|
// <GestureRecognizedEventArgs>
|
|
|
|
// <GestureRecognizedEventArgs>
|
|
|
|
public static EventHandler GestureRecognized { get; set; }
|
|
|
|
public static EventHandler GestureRecognized { get; set; }
|
|
|
@ -31,11 +35,51 @@ namespace KinectUtils
|
|
|
|
throw new NotImplementedException();
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void RemoveGesture(BaseGesture baseGesture) { throw new NotImplementedException(); }
|
|
|
|
public static void RemoveGesture(BaseGesture baseGesture)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//baseGesture.GestureRecognized -=
|
|
|
|
|
|
|
|
KnownGestures.Remove(baseGesture);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void StartAcquiringFrames(KinectManager manager) { throw new NotImplementedException(); }
|
|
|
|
public static void StartAcquiringFrames(KinectManager manager)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!isAcquiringFrame)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
KinectManager.KinectSensor.Open();
|
|
|
|
|
|
|
|
bodyFrameReader = KinectManager.KinectSensor.BodyFrameSource.OpenReader();
|
|
|
|
|
|
|
|
bodyFrameReader.FrameArrived += BodyFrameReader_FrameArrived;
|
|
|
|
|
|
|
|
isAcquiringFrame = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void StopAcquiringFrame(KinectManager manager) { throw new NotImplementedException(); }
|
|
|
|
public static void StopAcquiringFrame(KinectManager manager)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (isAcquiringFrame)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
KinectManager.KinectSensor.Close();
|
|
|
|
|
|
|
|
bodyFrameReader.FrameArrived -= BodyFrameReader_FrameArrived;
|
|
|
|
|
|
|
|
isAcquiringFrame = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void BodyFrameReader_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (var bodyFrame = e.FrameReference.AcquireFrame())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (bodyFrame != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Body[] bodies = new Body[bodyFrame.BodyCount];
|
|
|
|
|
|
|
|
bodyFrame.GetAndRefreshBodyData(bodies);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (Body body in bodies)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (body.IsTracked)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//postureHandUpRight.TestGesture(body);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|