equal
deleted
inserted
replaced
25 using System.Collections.Generic; |
25 using System.Collections.Generic; |
26 using System.Linq; |
26 using System.Linq; |
27 using System.Text; |
27 using System.Text; |
28 using Microsoft.Kinect; |
28 using Microsoft.Kinect; |
29 using System.Drawing; |
29 using System.Drawing; |
|
30 using Trakers.Debug; |
30 |
31 |
31 namespace Trakers.MainModule.Gestures |
32 namespace Trakers.Tracking.Gestures |
32 { |
33 { |
33 public class GestureDetector |
34 public class GestureDetector |
34 { |
35 { |
|
36 public DebugWindow debug; |
|
37 |
35 //Historique des positions du squelette. |
38 //Historique des positions du squelette. |
36 protected static List<List<Joint>> history = new List<List<Joint>>(); |
39 protected static List<List<Joint>> history = new List<List<Joint>>(); |
37 //protected JointCollection previousSkeleton; |
40 //protected JointCollection previousSkeleton; |
38 |
41 |
39 //Voici les ID des noeuds d'un squelette : variables magiques en attente de factorisation. |
42 //Voici les ID des noeuds d'un squelette : variables magiques en attente de factorisation. |
53 //Estimation du nombre d'indexes par seconde (framerate). |
56 //Estimation du nombre d'indexes par seconde (framerate). |
54 protected int indexesPerSecond = 30; |
57 protected int indexesPerSecond = 30; |
55 //Estimation du nombre de positions du squelette à vérifier dans l'historique. |
58 //Estimation du nombre de positions du squelette à vérifier dans l'historique. |
56 protected int indexesToCheck;// = gesturePeriod * indexesPerSecond; |
59 protected int indexesToCheck;// = gesturePeriod * indexesPerSecond; |
57 |
60 |
58 public GestureDetector() |
61 public GestureDetector(DebugWindow _debug) |
59 { |
62 { |
60 |
63 debug = _debug; |
61 } |
64 } |
62 |
65 |
63 //Setters. |
66 //Setters. |
64 public void setRefDistance(float _refDistance) |
67 public void setRefDistance(float _refDistance) |
65 { |
68 { |
113 if (history.Count > 90) |
116 if (history.Count > 90) |
114 { |
117 { |
115 history.RemoveAt(0); |
118 history.RemoveAt(0); |
116 } |
119 } |
117 } |
120 } |
118 |
|
119 /*public bool CheckForHandWave() |
|
120 { |
|
121 //Crée un historique de squelette local, puisque l'historique est mis à jour toutes les ~1/30 s. |
|
122 List<Skeleton> history = new List<Skeleton>(history); |
|
123 //Si il n'y a pas assez de positions dans l'historique local pour vérifier le geste. |
|
124 if (history.Count < indexesToCheck) |
|
125 return false; |
|
126 |
|
127 float refDistance = Math.Abs(history[0].Joints.ElementAt(spineID).Position.Y - history[0].Joints.ElementAt(hipCenterID).Position.Y); |
|
128 float startPos = history[history.Count - indexesToCheck].Joints.ElementAt(handRightID).Position.X; |
|
129 bool movedRight = false; |
|
130 for (int i = history.Count - indexesToCheck + 1; i < history.Count; i++) |
|
131 { |
|
132 // Throughout the gesture period, right hand should be above theelbow, below the head and hand should be higher than the wrist |
|
133 if (!(history[i].Joints[JointID.HandRight].Position.Y > history[i].Joints[JointID.ElbowRight].Position.Y + refDistance && |
|
134 history[i].Joints[JointID.HandRight].Position.Y < history[i].Joints[JointID.Head].Position.Y && |
|
135 history[i].Joints[JointID.HandRight].Position.Y > history[i].Joints[JointID.WristRight].Position.Y + refDistance / 4)) |
|
136 { |
|
137 return false; |
|
138 } |
|
139 // If the previous condition was met, check if the hand has moved to the right |
|
140 if (history[i].Joints[JointID.HandRight].Position.X >= startPos + refDistance / 2 && !movedRight) |
|
141 { |
|
142 movedRight = true; |
|
143 } |
|
144 // If the hand did move to the right, check if it returned near the original position |
|
145 if (movedRight && history[i].Joints[JointID.HandRight].Position.X <= startPos + refDistance / 5) |
|
146 { |
|
147 skeletonHistory.Clear(); |
|
148 return true; |
|
149 } |
|
150 } |
|
151 return false; |
|
152 }*/ |
|
153 } |
121 } |
154 } |
122 } |