|
|
|
@ -7,31 +7,80 @@ using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace KinectUtils
|
|
|
|
|
{
|
|
|
|
|
class BaseMapping<T>
|
|
|
|
|
public abstract class BaseMapping<T>
|
|
|
|
|
{
|
|
|
|
|
public void SubscribeToStartGesture(BaseGesture gesture)
|
|
|
|
|
protected bool running = false;
|
|
|
|
|
public event EventHandler<OnMappingEventArgs<T>> OnMapping;
|
|
|
|
|
|
|
|
|
|
protected BaseMapping(BaseGesture startGesture, BaseGesture endGesture)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
SubscribeToStartGesture(startGesture);
|
|
|
|
|
SubscribeToEndGesture(endGesture);
|
|
|
|
|
// Assuming GestureManager has an event that provides processed body data
|
|
|
|
|
GestureManager.ProcessedBodyFrameArrived += OnProcessedBodyFrameArrived;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SubscribeToEndGesture(BaseGesture gesture)
|
|
|
|
|
protected abstract T Mapping(Body body);
|
|
|
|
|
|
|
|
|
|
protected bool TestMapping(Body body, out T output)
|
|
|
|
|
{
|
|
|
|
|
output = default(T);
|
|
|
|
|
if (running)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
output = Mapping(body);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SubscribeToToggleGesture(BaseGesture gesture)
|
|
|
|
|
protected void SubscribeToStartGesture(BaseGesture gesture)
|
|
|
|
|
{
|
|
|
|
|
gesture.GestureRecognized += (sender, e) => { if (!running) running = true; };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void SubscribeToEndGesture(BaseGesture gesture)
|
|
|
|
|
{
|
|
|
|
|
gesture.GestureRecognized += (sender, e) => { if (running) running = false; };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Assuming your GestureManager provides a similar event
|
|
|
|
|
protected void OnProcessedBodyFrameArrived(object sender, ProcessedBodyFrameEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
foreach (var body in e.Bodies)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
if (body.IsTracked)
|
|
|
|
|
{
|
|
|
|
|
T output;
|
|
|
|
|
if (TestMapping(body, out output))
|
|
|
|
|
{
|
|
|
|
|
OnMapping?.Invoke(this, new OnMappingEventArgs<T>(output));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected T Mapping(Body body)
|
|
|
|
|
public class OnMappingEventArgs<T> : EventArgs
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
public T MappedValue { get; private set; }
|
|
|
|
|
|
|
|
|
|
public OnMappingEventArgs(T mappedValue)
|
|
|
|
|
{
|
|
|
|
|
MappedValue = mappedValue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool TestMapping(Body body, out T output)
|
|
|
|
|
// Custom EventArgs to be used within your application logic
|
|
|
|
|
// This is not from the Kinect SDK, but rather a custom class to pass along processed body data
|
|
|
|
|
public class ProcessedBodyFrameEventArgs : EventArgs
|
|
|
|
|
{
|
|
|
|
|
public Body[] Bodies { get; private set; }
|
|
|
|
|
public Body ClosestBody { get; private set; }
|
|
|
|
|
|
|
|
|
|
public ProcessedBodyFrameEventArgs(Body[] bodies, Body closestBody)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
Bodies = bodies;
|
|
|
|
|
ClosestBody = closestBody;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|