--- a/middleware/Tracking/Gestures/JumpDetector.cs Wed May 30 10:22:46 2012 +0200
+++ b/middleware/Tracking/Gestures/JumpDetector.cs Thu Jun 21 16:52:56 2012 +0200
@@ -36,7 +36,7 @@
public JumpDetector(DebugWindow _debug) : base(_debug)
{
- gesturePeriod = (float)1;
+ gesturePeriod = (float)1.5;
indexesPerSecond = 30;
indexesToCheck = (int)(gesturePeriod * indexesPerSecond);
}
@@ -70,31 +70,75 @@
* HeadFarAboveBaseLine
*/
- //La distance de référence est ici la distance entre le milieu du dos et le milieu des épaules.
- refDistance = Math.Abs(localHistory[0][(int)JointType.Spine].Position.Y - localHistory[0][(int)JointType.ShoulderCenter].Position.Y);
+ //La distance de référence est ici la distance entre les épaules et les hanches.
+ refDistance = Math.Abs(localHistory[0][(int)JointType.ShoulderCenter].Position.Y - localHistory[0][(int)JointType.HipCenter].Position.Y);
//On commence la position pour les indexesToCheck dernières postures (celle à l'index 0 étant la dernière).
int beginIdx = localHistory.Count - indexesToCheck + 1;
- int middleIdx = localHistory.Count - indexesToCheck / 2;
- //bool middleOK = true
+ int middleIdx = 0;
+ int endIdx = 0;
bool topOfJump = false;
-
-
+ bool probableJump = false;
//De la position p1 à pn, on suit l'algorithme.
for (int i = beginIdx ; i < localHistory.Count ; i++)
{
-
- if (localHistory[i][(int)JointType.HandRight].Position.Y < localHistory[beginIdx][(int)JointType.HandRight].Position.Y + refDistance &&
- localHistory[i - 1][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.HandRight].Position.Y)
+ if (localHistory[i][(int)JointType.Spine].Position.Y + refDistance / 2 < localHistory[beginIdx][(int)JointType.Spine].Position.Y)
{
topOfJump = true;
- //Console.Out.WriteLine("TOP");
+ middleIdx = i;
+ debug.onR0(true);
}
- if (localHistory[i - 1][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HandRight].Position.Y && !topOfJump)
- return false;
+ if (localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[beginIdx][(int)JointType.Spine].Position.Y)
+ {
+ debug.onR0(false);
+ debug.onR1(false);
+ debug.onR2(false);
+ }
+ }
+
+ if (topOfJump)
+ {
+ for (int i = middleIdx; i < localHistory.Count; i++)
+ {
+ if (Math.Abs(localHistory[beginIdx][(int)JointType.Spine].Position.Y - localHistory[i][(int)JointType.Spine].Position.Y) < refDistance / 5 ||
+ localHistory[beginIdx][(int)JointType.Spine].Position.Y < localHistory[i][(int)JointType.Spine].Position.Y)
+ {
+ probableJump = true;
+ endIdx = i;
+ debug.onR1(true);
+ //Console.Out.WriteLine("TOP");
+ }
+ }
+ }
+ else
+ {
+ debug.onR0(false);
+ debug.onR1(false);
+ debug.onR2(false);
+ return false;
+ }
+
+ if (probableJump)
+ {
+ if (Math.Abs(localHistory[beginIdx][(int)JointType.Spine].Position.Z - localHistory[endIdx][(int)JointType.Spine].Position.Z) < 0.10)
+ {
+ debug.onR2(true);
+ return true;
+ }
+ }
+ else
+ {
+ debug.onR0(false);
+ debug.onR1(false);
+ debug.onR2(false);
+ return false;
+ }
+
+ //if (localHistory[i - 1][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HandRight].Position.Y && !topOfJump)
+ //return false;
//Si la position Y de la main est plus haute que la tête
//OU si la position Y de la main est plus basse que la hanche
@@ -102,11 +146,11 @@
//OU si la nouvelle position X de la main est plus éloignée de la distance N par rapport à la première position X
//OU si la nouvelle position Y de la main est plus éloignée de la distance N par rapport à la première position Y
//Alors la main en question ne fait pas de push.
- if (localHistory[i - 1][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HandRight].Position.Y &&
+ /*if (localHistory[i - 1][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HandRight].Position.Y &&
topOfJump || localHistory[i - 1][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.HandRight].Position.Y &&
!topOfJump)
- return false;
- }
+ return false;*/
+ //}
//Console.Out.WriteLine("OK");