1 using System; |
1 /* |
|
2 * Projet : TraKERS |
|
3 * Module : MIDDLEWARE |
|
4 * Sous-Module : Tracking/Gestures |
|
5 * Classe : GestureDetector |
|
6 * |
|
7 * Auteur : alexandre.bastien@iri.centrepompidou.fr |
|
8 * |
|
9 * Fonctionnalités : Reçoit les positions des noeuds envoyés par la classe de manipulation de la Kinect |
|
10 * et les stocke dans un historique. |
|
11 * Contient également des variables propres à toute gesture : distance de référence, point de départ, |
|
12 * durée de la gesture, FPS et nombre de frames à traiter. |
|
13 */ |
|
14 |
|
15 using System; |
2 using System.Collections.Generic; |
16 using System.Collections.Generic; |
3 using System.Linq; |
17 using System.Linq; |
4 using System.Text; |
18 using System.Text; |
5 using Microsoft.Kinect; |
19 using Microsoft.Kinect; |
6 using System.Drawing; |
20 using System.Drawing; |
8 namespace Trakers.Tracking.Gestures |
22 namespace Trakers.Tracking.Gestures |
9 { |
23 { |
10 public class GestureDetector |
24 public class GestureDetector |
11 { |
25 { |
12 //Historique des positions du squelette. |
26 //Historique des positions du squelette. |
13 protected List<List<Joint>> history = new List<List<Joint>>(); |
27 protected static List<List<Joint>> history = new List<List<Joint>>(); |
14 //protected JointCollection previousSkeleton; |
28 //protected JointCollection previousSkeleton; |
15 |
29 |
16 //Voici les ID des noeuds d'un squelette. |
30 //Voici les ID des noeuds d'un squelette : variables magiques en attente de factorisation. |
17 protected int hipCenterID = 0, spineID = 1, shoulderCenterID = 2, headID = 3; |
31 protected int hipCenterID = 0, spineID = 1, shoulderCenterID = 2, headID = 3; |
18 protected int shoulderLeftID = 4, elbowLeftID = 5, wristLeftID = 6, handLeftID = 7; |
32 protected int shoulderLeftID = 4, elbowLeftID = 5, wristLeftID = 6, handLeftID = 7; |
19 protected int shoulderRightID = 8, elbowRightID = 9, wristRightID = 10, handRightID = 11; |
33 protected int shoulderRightID = 8, elbowRightID = 9, wristRightID = 10, handRightID = 11; |
20 protected int hipLeftID = 12, kneeLeftID = 13, ankleLeftID = 14, footLeftID = 15; |
34 protected int hipLeftID = 12, kneeLeftID = 13, ankleLeftID = 14, footLeftID = 15; |
21 protected int hipRightID = 16, kneeRightID = 17, ankleRightID = 18, footRightID = 19; |
35 protected int hipRightID = 16, kneeRightID = 17, ankleRightID = 18, footRightID = 19; |
81 return indexesToCheck; |
95 return indexesToCheck; |
82 } |
96 } |
83 |
97 |
84 //Stocke les gestes du skelette pour ~3 seconds (si on prend en compte que le framerate de la Kinect |
98 //Stocke les gestes du skelette pour ~3 seconds (si on prend en compte que le framerate de la Kinect |
85 //est de ~30 fps. |
99 //est de ~30 fps. |
86 public void UpdateSkeletonHistory(List<Joint> latestSkeleton) |
100 public static void UpdateSkeletonHistory(List<Joint> latestSkeleton) |
87 { |
101 { |
88 /*if (previousSkeleton == null) |
102 history.Add(latestSkeleton); |
89 previousSkeleton = latestSkeleton; |
103 |
90 else if (previousSkeleton != latestSkeleton) |
104 if (history.Count > 90) |
91 {*/ |
105 { |
92 history.Add(latestSkeleton); |
106 history.RemoveAt(0); |
93 /*if (history.Count > 3) |
107 } |
94 { |
|
95 System.Console.WriteLine(history[0][0].Position.X + " " + history[1][0].Position.X + " " + history[2][0].Position.X); |
|
96 }*/ |
|
97 if (history.Count > 90) |
|
98 { |
|
99 history.RemoveAt(0); |
|
100 } |
|
101 //} |
|
102 } |
108 } |
103 |
109 |
104 /*public bool CheckForHandWave() |
110 /*public bool CheckForHandWave() |
105 { |
111 { |
106 //Crée un historique de squelette local, puisque l'historique est mis à jour toutes les ~1/30 s. |
112 //Crée un historique de squelette local, puisque l'historique est mis à jour toutes les ~1/30 s. |