started posture

exo2
Nicolas FRANCO 1 year ago
parent 078b36d431
commit 28c8bb6b1f

@ -7,17 +7,39 @@ using Microsoft.Kinect;
namespace KinectUtils
{
/// <summary>
/// The base gesture.
/// </summary>
public abstract class BaseGesture
{
/// <summary>
/// The base gesture initializer.
/// </summary>
public BaseGesture() { }
/// <summary>
/// The gesture name.
/// </summary>
public string GestureName { get; set; }
// <GestureRecognizedEventArgs> a faire nous mêmes
public EventHandler GestureRecognized { get; set; }
/// <summary>
/// The gesture recognized event.
/// </summary>
public EventHandler<GestureRecognizedEventArgs> GestureRecognized { get; set; }
/// <summary>
/// The test gesture.
/// </summary>
/// <param name="body"></param>
public abstract void TestGesture(Body body);
protected void OnGestureRecognized() { }
/// <summary>
/// The on gesture recognized method.
/// </summary>
protected void OnGestureRecognized()
{
GestureRecognized?.Invoke(this, new GestureRecognizedEventArgs(GestureName));
}
}
}

@ -0,0 +1,25 @@
using Microsoft.Kinect;
namespace KinectUtils
{
/// <summary>
/// The gesture recognized event args.
/// </summary>
public class GestureRecognizedEventArgs
{
/// <summary>
/// The gesture name.
/// </summary>
public string GestureName { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="GestureRecognizedEventArgs"/> class.
/// </summary>
/// <param name="gestureName"></param>
/// <param name="body"></param>
public GestureRecognizedEventArgs(string gestureName)
{
GestureName = gestureName;
}
}
}

@ -46,6 +46,7 @@
<ItemGroup>
<Compile Include="BaseGesture.cs" />
<Compile Include="GestureManager.cs" />
<Compile Include="GestureRecognizedEventArgs.cs" />
<Compile Include="IGestureFactory.cs" />
<Compile Include="Posture.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

@ -7,8 +7,16 @@ using System.Threading.Tasks;
namespace KinectUtils
{
/// <summary>
/// The posture class.
/// </summary>
public abstract class Posture : BaseGesture
{
/// <summary>
/// Tests the posture.
/// </summary>
/// <param name="body">The body</param>
/// <returns></returns>
protected abstract bool TestPosture(Body body);
}
}

@ -44,6 +44,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="PostureHandUpLeft.cs" />
<Compile Include="PostureHandUpRight.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

@ -0,0 +1,45 @@
using KinectUtils;
using Microsoft.Kinect;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyGestureBank
{
/// <summary>
/// The left hand up posture.
/// </summary>
public class PostureHandUpLeft : Posture
{
public PostureHandUpLeft()
{
GestureName = "HandUpLeft";
}
/// <summary>
/// The test gesture method.
/// </summary>
/// <param name="body">The body</param>
public override void TestGesture(Body body)
{
if (TestPosture(body))
{
OnGestureRecognized();
}
}
/// <summary>
/// The test posture method.
/// </summary>
/// <param name="body"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
protected override bool TestPosture(Body body)
{
// Check if the left hand is above the left shoulder
return body.Joints[JointType.HandLeft].Position.Y > body.Joints[JointType.ShoulderLeft].Position.Y;
}
}
}

@ -8,16 +8,34 @@ using Microsoft.Kinect;
namespace MyGestureBank
{
/// <summary>
/// The hand up right posture.
/// </summary>
public class PostureHandUpRight : Posture
{
/// <summary>
/// PostureHandUpRight constructor.
/// </summary>
public PostureHandUpRight()
{
GestureName = "HandUpRight";
}
/// <summary>
/// The test gesture method.
/// </summary>
/// <param name="body"></param>
public override void TestGesture(Body body)
{
throw new NotImplementedException();
if(TestPosture(body))
{
OnGestureRecognized();
}
}
protected override bool TestPosture(Body body)
{
throw new NotImplementedException();
return body.Joints[JointType.HandRight].Position.Y > body.Joints[JointType.ShoulderRight].Position.Y;
}
}
}

Loading…
Cancel
Save