middleware/Tracking/Postures/FallDetector.cs
changeset 37 37ebedd84755
child 39 15b11d291417
equal deleted inserted replaced
36:25e71ada2a6d 37:37ebedd84755
       
     1 /*
       
     2 * This file is part of the TraKERS\Middleware package.
       
     3 *
       
     4 * (c) IRI <http://www.iri.centrepompidou.fr/>
       
     5 *
       
     6 * For the full copyright and license information, please view the LICENSE
       
     7 * file that was distributed with this source code.
       
     8 */
       
     9 
       
    10 /*
       
    11  * Projet : TraKERS
       
    12  * Module : MIDDLEWARE
       
    13  * Sous-Module : Tracking/Gestures
       
    14  * Classe : JumpDetector
       
    15  * 
       
    16  * Auteur : alexandre.bastien@iri.centrepompidou.fr
       
    17  * 
       
    18  * Fonctionnalités : Permet de détecter si l'utilisateur a sauté, en se basant sur
       
    19  * des règles appliquées à la positions des noeuds dans le temps.
       
    20  * 
       
    21  * P.S : Cette partie est encore en développement.
       
    22  */
       
    23 
       
    24 using System;
       
    25 using System.Collections.Generic;
       
    26 using System.Linq;
       
    27 using System.Text;
       
    28 using Microsoft.Kinect;
       
    29 using Trakers.Debug;
       
    30 
       
    31 namespace Trakers.Tracking.Postures
       
    32 {
       
    33     public class FallDetector : PostureDetector
       
    34     {
       
    35         static int n = 0;
       
    36 
       
    37         public FallDetector(DebugWindow _debug)
       
    38             : base(_debug)
       
    39         {
       
    40         }
       
    41 
       
    42         /*
       
    43          * Méthode de détection du fall.
       
    44          */
       
    45         public bool CheckForFall()
       
    46         {
       
    47             //Crée un état local afin de pouvoir analyser s'il y a une posture.
       
    48             List<Joint> localState = new List<Joint>(currentState);
       
    49 
       
    50             /*if (localState[(int)JointType.KneeLeft].Position.Z + 0.10 < localState[(int)JointType.HipCenter].Position.Z)
       
    51                 debug.onR0(true);
       
    52             else
       
    53                 debug.onR0(false);
       
    54             if(localState[(int)JointType.KneeRight].Position.Z + 0.10 < localState[(int)JointType.HipCenter].Position.Z)
       
    55                 debug.onR1(true);
       
    56             else
       
    57                 debug.onR1(false);
       
    58             if (Math.Abs(localState[(int)JointType.HipCenter].Position.Z - localState[(int)JointType.Head].Position.Z) <= 0.20)
       
    59                 debug.onR2(true);
       
    60             else
       
    61                 debug.onR2(false);*/
       
    62 
       
    63             //Si les genoux ne sont pas éloignés d'au moins 20cm vers l'avant par rapport aux hanches
       
    64             //OU si les hanches et la tête ne sont pas au même niveau avec 20 cm d'erreur.
       
    65             //Alors on ne fait pas un fall.
       
    66             if (localState[(int)JointType.KneeLeft].Position.Z + 0.15 >= localState[(int)JointType.HipCenter].Position.Z ||
       
    67                 localState[(int)JointType.KneeRight].Position.Z + 0.15 >= localState[(int)JointType.HipCenter].Position.Z ||
       
    68                 //||
       
    69                 Math.Abs(localState[(int)JointType.HipCenter].Position.Z - localState[(int)JointType.Head].Position.Z) > 0.20)
       
    70                 return false;
       
    71             return true;
       
    72         }
       
    73     }
       
    74 }