middleware/Tracking/Postures/FallDetector.cs
changeset 39 15b11d291417
parent 37 37ebedd84755
equal deleted inserted replaced
38:08f96aad0127 39:15b11d291417
     1 /*
     1 /*
     2 * This file is part of the TraKERS\Middleware package.
     2 * This file is part of the TraKERS\Middleware package.
     3 *
     3 *
     4 * (c) IRI <http://www.iri.centrepompidou.fr/>
     4 * (c) IRI <http://www.iri.centrepompidou.fr/>
     5 *
     5 *
     6 * For the full copyright and license information, please view the LICENSE
     6 * For the full copyright and license information, please view the LICENSE
     9 
     9 
    10 /*
    10 /*
    11  * Projet : TraKERS
    11  * Projet : TraKERS
    12  * Module : MIDDLEWARE
    12  * Module : MIDDLEWARE
    13  * Sous-Module : Tracking/Gestures
    13  * Sous-Module : Tracking/Gestures
    14  * Classe : JumpDetector
    14  * Classe : FallDetector
    15  * 
    15  * 
    16  * Auteur : alexandre.bastien@iri.centrepompidou.fr
    16  * Auteur : alexandre.bastien@iri.centrepompidou.fr
    17  * 
    17  * 
    18  * Fonctionnalités : Permet de détecter si l'utilisateur a sauté, en se basant sur
    18  * Fonctionnalités : Permet de détecter si l'utilisateur est tombé, en se basant sur
    19  * des règles appliquées à la positions des noeuds dans le temps.
    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  */
    20  */
    23 
    21 
    24 using System;
    22 using System;
    25 using System.Collections.Generic;
    23 using System.Collections.Generic;
    26 using System.Linq;
    24 using System.Linq;
    45         public bool CheckForFall()
    43         public bool CheckForFall()
    46         {
    44         {
    47             //Crée un état local afin de pouvoir analyser s'il y a une posture.
    45             //Crée un état local afin de pouvoir analyser s'il y a une posture.
    48             List<Joint> localState = new List<Joint>(currentState);
    46             List<Joint> localState = new List<Joint>(currentState);
    49 
    47 
    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
    48             //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.
    49             //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.
    50             //Alors on ne fait pas un fall.
    66             if (localState[(int)JointType.KneeLeft].Position.Z + 0.15 >= localState[(int)JointType.HipCenter].Position.Z ||
    51             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 ||
    52                 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)
    53                 Math.Abs(localState[(int)JointType.HipCenter].Position.Z - localState[(int)JointType.Head].Position.Z) > 0.20)
    70                 return false;
    54                 return false;
    71             return true;
    55             return true;
    72         }
    56         }
    73     }
    57     }