middleware/Tracking/Gestures/SwipeDetector.cs
changeset 37 37ebedd84755
parent 27 6c08d4d7219e
equal deleted inserted replaced
36:25e71ada2a6d 37:37ebedd84755
    63 
    63 
    64             //De la position p1 à pn, on suit l'algorithme.
    64             //De la position p1 à pn, on suit l'algorithme.
    65             for (int i = localHistory.Count - indexesToCheck + 1; i < localHistory.Count; i++)
    65             for (int i = localHistory.Count - indexesToCheck + 1; i < localHistory.Count; i++)
    66             {
    66             {
    67                 //Si la position Y de la main est plus haute que la tête
    67                 //Si la position Y de la main est plus haute que la tête
    68                 //OU si la position Y de la main est plus basse que la hanche
    68                 //OU si la position Y de la main est plus basse que la hanche (les genoux)
    69                 //OU si la nouvelle position X de la main est à droite de la précédente
    69                 //OU si la nouvelle position X de la main est à droite de la précédente
    70                 //OU si la nouvelle position Y de la main est plus éloignée de la distance N par rapport à la première position Y
    70                 //OU si la nouvelle position Y de la main est plus éloignée de la distance N par rapport à la première position Y
    71                 //Alors on retourne faux.
    71                 //Alors on retourne faux.
    72                 if (localHistory[i][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.Head].Position.Y ||
    72                 if (localHistory[i][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.Head].Position.Y ||
    73                 localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HipCenter].Position.Y ||
    73                 //localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HipCenter].Position.Y ||
       
    74                 localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.KneeLeft].Position.Y ||
       
    75                 localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.KneeRight].Position.Y ||
    74                 localHistory[i][(int)JointType.HandRight].Position.X > localHistory[i - 1][(int)JointType.HandRight].Position.X ||
    76                 localHistory[i][(int)JointType.HandRight].Position.X > localHistory[i - 1][(int)JointType.HandRight].Position.X ||
    75                 Math.Abs(localHistory[i][(int)JointType.HandRight].Position.Y - startPoint.Y) > refDistance / 2)
    77                 Math.Abs(localHistory[i][(int)JointType.HandRight].Position.Y - startPoint.Y) > refDistance / 2)
    76                     return false;
    78                     return false;
    77             }
    79             }
    78 
    80 
   118 
   120 
   119             //De la position p1 à pn, on suit l'algorithme.
   121             //De la position p1 à pn, on suit l'algorithme.
   120             for (int i = localHistory.Count - indexesToCheck + 1; i < localHistory.Count; i++)
   122             for (int i = localHistory.Count - indexesToCheck + 1; i < localHistory.Count; i++)
   121             {
   123             {
   122                 //Si la position Y de la main est plus haute que la tête
   124                 //Si la position Y de la main est plus haute que la tête
   123                 //OU si la position Y de la main est plus basse que la hanche
   125                 //OU si la position Y de la main est plus basse que la hanche (les genoux)
   124                 //OU si la nouvelle position X de la main est à gauche de la précédente
   126                 //OU si la nouvelle position X de la main est à gauche de la précédente
   125                 //OU si la nouvelle position Y de la main est plus éloignée de la distance N par rapport à la première position Y
   127                 //OU si la nouvelle position Y de la main est plus éloignée de la distance N par rapport à la première position Y
   126                 //Alors on retourne faux.
   128                 //Alors on retourne faux.
   127                 if (localHistory[i][(int)JointType.HandLeft].Position.Y < localHistory[i][(int)JointType.Head].Position.Y ||
   129                 if (localHistory[i][(int)JointType.HandLeft].Position.Y < localHistory[i][(int)JointType.Head].Position.Y ||
   128                 localHistory[i][(int)JointType.HandLeft].Position.Y > localHistory[i][(int)JointType.HipCenter].Position.Y ||
   130                 //localHistory[i][(int)JointType.HandLeft].Position.Y > localHistory[i][(int)JointType.HipCenter].Position.Y ||
       
   131                 localHistory[i][(int)JointType.HandLeft].Position.Y > localHistory[i][(int)JointType.KneeLeft].Position.Y ||
       
   132                 localHistory[i][(int)JointType.HandLeft].Position.Y > localHistory[i][(int)JointType.KneeRight].Position.Y ||
   129                 localHistory[i][(int)JointType.HandLeft].Position.X < localHistory[i - 1][(int)JointType.HandLeft].Position.X ||
   133                 localHistory[i][(int)JointType.HandLeft].Position.X < localHistory[i - 1][(int)JointType.HandLeft].Position.X ||
   130                 Math.Abs(localHistory[i][(int)JointType.HandLeft].Position.Y - startPoint.Y) > refDistance / 2)
   134                 Math.Abs(localHistory[i][(int)JointType.HandLeft].Position.Y - startPoint.Y) > refDistance / 2)
   131                     return false;
   135                     return false;
   132             }
   136             }
   133 
   137