|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using Microsoft.Kinect;
|
|
|
|
|
using KinectUtils;
|
|
|
|
|
using Microsoft.Kinect;
|
|
|
|
|
using MyGestureBank;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
@ -11,51 +12,63 @@ namespace PostureTester
|
|
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
|
|
|
|
private static List<Tuple<JointType, JointType>> bones = new List<Tuple<JointType, JointType>>();
|
|
|
|
|
private static KinectSensor kinectSensor;
|
|
|
|
|
private static PostureHandUpRight postureHandUpRight = new PostureHandUpRight();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
// Create a body
|
|
|
|
|
Body[] body = new Body[1];
|
|
|
|
|
|
|
|
|
|
// Create a posture
|
|
|
|
|
PostureHandUpRight postureHandUpRight = new PostureHandUpRight();
|
|
|
|
|
PostureHandUpLeft postureHandUpLeft = new PostureHandUpLeft();
|
|
|
|
|
|
|
|
|
|
// Make the body do the posture
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.Head, JointType.Neck));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.Neck, JointType.SpineShoulder));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.SpineShoulder, JointType.SpineMid));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.SpineMid, JointType.SpineBase));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.SpineShoulder, JointType.ShoulderRight));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.SpineShoulder, JointType.ShoulderLeft));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.SpineBase, JointType.HipRight));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.SpineBase, JointType.HipLeft));
|
|
|
|
|
|
|
|
|
|
// Bras droit
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.ShoulderRight, JointType.ElbowRight));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.ElbowRight, JointType.WristRight));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.WristRight, JointType.HandRight));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.HandRight, JointType.HandTipRight));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.WristRight, JointType.ThumbRight));
|
|
|
|
|
|
|
|
|
|
// Bras gauche
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.ShoulderLeft, JointType.ElbowLeft));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.ElbowLeft, JointType.WristLeft));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.WristLeft, JointType.HandLeft));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.HandLeft, JointType.HandTipLeft));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.WristLeft, JointType.ThumbLeft));
|
|
|
|
|
|
|
|
|
|
// Jambe droite
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.HipRight, JointType.KneeRight));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.KneeRight, JointType.AnkleRight));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.AnkleRight, JointType.FootRight));
|
|
|
|
|
|
|
|
|
|
// Jambe gauche
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.HipLeft, JointType.KneeLeft));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.KneeLeft, JointType.AnkleLeft));
|
|
|
|
|
bones.Add(new Tuple<JointType, JointType>(JointType.AnkleLeft, JointType.FootLeft));
|
|
|
|
|
kinectSensor = KinectSensor.GetDefault();
|
|
|
|
|
postureHandUpRight.GestureRecognized += PostureHandUpRight_GestureRecognized;
|
|
|
|
|
|
|
|
|
|
if (kinectSensor != null)
|
|
|
|
|
{
|
|
|
|
|
kinectSensor.Open();
|
|
|
|
|
|
|
|
|
|
// Utilisation du bloc using pour bodyFrameReader
|
|
|
|
|
using (var bodyFrameReader = kinectSensor.BodyFrameSource.OpenReader())
|
|
|
|
|
{
|
|
|
|
|
if (bodyFrameReader != null)
|
|
|
|
|
{
|
|
|
|
|
// Abonnement à l'événement FrameArrived
|
|
|
|
|
bodyFrameReader.FrameArrived += BodyFrameReader_FrameArrived;
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Lecture des données du corps en cours... Appuyez sur une touche pour quitter.");
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (kinectSensor != null)
|
|
|
|
|
{
|
|
|
|
|
kinectSensor.Close();
|
|
|
|
|
kinectSensor = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void PostureHandUpRight_GestureRecognized(object sender, GestureRecognizedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Posture Hand Up Right reconnue !");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|