68 * OR |
68 * OR |
69 * |
69 * |
70 * HeadFarAboveBaseLine |
70 * HeadFarAboveBaseLine |
71 */ |
71 */ |
72 |
72 |
73 //La distance de référence est ici la distance entre le milieu du dos et le milieu des épaules. |
73 //La distance de référence est ici la distance entre les épaules et les hanches. |
74 refDistance = Math.Abs(localHistory[0][(int)JointType.Spine].Position.Y - localHistory[0][(int)JointType.ShoulderCenter].Position.Y); |
74 refDistance = Math.Abs(localHistory[0][(int)JointType.ShoulderCenter].Position.Y - localHistory[0][(int)JointType.HipCenter].Position.Y); |
75 //On commence la position pour les indexesToCheck dernières postures (celle à l'index 0 étant la dernière). |
75 //On commence la position pour les indexesToCheck dernières postures (celle à l'index 0 étant la dernière). |
76 |
76 |
77 int beginIdx = localHistory.Count - indexesToCheck + 1; |
77 int beginIdx = localHistory.Count - indexesToCheck + 1; |
78 int middleIdx = localHistory.Count - indexesToCheck / 2; |
|
79 |
78 |
80 //bool middleOK = true |
79 int middleIdx = 0; |
|
80 int endIdx = 0; |
81 bool topOfJump = false; |
81 bool topOfJump = false; |
82 |
82 bool probableJump = false; |
83 |
|
84 |
83 |
85 //De la position p1 à pn, on suit l'algorithme. |
84 //De la position p1 à pn, on suit l'algorithme. |
86 for (int i = beginIdx ; i < localHistory.Count ; i++) |
85 for (int i = beginIdx ; i < localHistory.Count ; i++) |
87 { |
86 { |
88 |
87 if (localHistory[i][(int)JointType.Spine].Position.Y + refDistance / 2 < localHistory[beginIdx][(int)JointType.Spine].Position.Y) |
89 if (localHistory[i][(int)JointType.HandRight].Position.Y < localHistory[beginIdx][(int)JointType.HandRight].Position.Y + refDistance && |
|
90 localHistory[i - 1][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.HandRight].Position.Y) |
|
91 { |
88 { |
92 topOfJump = true; |
89 topOfJump = true; |
93 //Console.Out.WriteLine("TOP"); |
90 middleIdx = i; |
|
91 debug.onR0(true); |
94 } |
92 } |
95 |
93 |
96 if (localHistory[i - 1][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HandRight].Position.Y && !topOfJump) |
94 if (localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[beginIdx][(int)JointType.Spine].Position.Y) |
97 return false; |
95 { |
|
96 debug.onR0(false); |
|
97 debug.onR1(false); |
|
98 debug.onR2(false); |
|
99 } |
|
100 } |
|
101 |
|
102 if (topOfJump) |
|
103 { |
|
104 for (int i = middleIdx; i < localHistory.Count; i++) |
|
105 { |
|
106 if (Math.Abs(localHistory[beginIdx][(int)JointType.Spine].Position.Y - localHistory[i][(int)JointType.Spine].Position.Y) < refDistance / 5 || |
|
107 localHistory[beginIdx][(int)JointType.Spine].Position.Y < localHistory[i][(int)JointType.Spine].Position.Y) |
|
108 { |
|
109 probableJump = true; |
|
110 endIdx = i; |
|
111 debug.onR1(true); |
|
112 //Console.Out.WriteLine("TOP"); |
|
113 } |
|
114 } |
|
115 } |
|
116 else |
|
117 { |
|
118 debug.onR0(false); |
|
119 debug.onR1(false); |
|
120 debug.onR2(false); |
|
121 return false; |
|
122 } |
|
123 |
|
124 if (probableJump) |
|
125 { |
|
126 if (Math.Abs(localHistory[beginIdx][(int)JointType.Spine].Position.Z - localHistory[endIdx][(int)JointType.Spine].Position.Z) < 0.10) |
|
127 { |
|
128 debug.onR2(true); |
|
129 return true; |
|
130 } |
|
131 } |
|
132 else |
|
133 { |
|
134 debug.onR0(false); |
|
135 debug.onR1(false); |
|
136 debug.onR2(false); |
|
137 return false; |
|
138 } |
|
139 |
|
140 //if (localHistory[i - 1][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HandRight].Position.Y && !topOfJump) |
|
141 //return false; |
98 |
142 |
99 //Si la position Y de la main est plus haute que la tête |
143 //Si la position Y de la main est plus haute que la tête |
100 //OU si la position Y de la main est plus basse que la hanche |
144 //OU si la position Y de la main est plus basse que la hanche |
101 //OU si la nouvelle position Z de la main est moins profonde que la précédente |
145 //OU si la nouvelle position Z de la main est moins profonde que la précédente |
102 //OU si la nouvelle position X de la main est plus éloignée de la distance N par rapport à la première position X |
146 //OU si la nouvelle position X de la main est plus éloignée de la distance N par rapport à la première position X |
103 //OU si la nouvelle position Y de la main est plus éloignée de la distance N par rapport à la première position Y |
147 //OU si la nouvelle position Y de la main est plus éloignée de la distance N par rapport à la première position Y |
104 //Alors la main en question ne fait pas de push. |
148 //Alors la main en question ne fait pas de push. |
105 if (localHistory[i - 1][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HandRight].Position.Y && |
149 /*if (localHistory[i - 1][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HandRight].Position.Y && |
106 topOfJump || localHistory[i - 1][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.HandRight].Position.Y && |
150 topOfJump || localHistory[i - 1][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.HandRight].Position.Y && |
107 !topOfJump) |
151 !topOfJump) |
108 return false; |
152 return false;*/ |
109 } |
153 //} |
110 |
154 |
111 //Console.Out.WriteLine("OK"); |
155 //Console.Out.WriteLine("OK"); |
112 |
156 |
113 //Si la distance en Z du geste a été plus courte que la distance N |
157 //Si la distance en Z du geste a été plus courte que la distance N |
114 //Alors on retourne faux. |
158 //Alors on retourne faux. |