|
39
|
1 |
/* |
|
37
|
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 |
|
39
|
14 |
* Classe : FallDetector |
|
37
|
15 |
* |
|
|
16 |
* Auteur : alexandre.bastien@iri.centrepompidou.fr |
|
|
17 |
* |
|
39
|
18 |
* Fonctionnalités : Permet de détecter si l'utilisateur est tombé, en se basant sur |
|
37
|
19 |
* des règles appliquées à la positions des noeuds dans le temps. |
|
|
20 |
*/ |
|
|
21 |
|
|
|
22 |
using System; |
|
|
23 |
using System.Collections.Generic; |
|
|
24 |
using System.Linq; |
|
|
25 |
using System.Text; |
|
|
26 |
using Microsoft.Kinect; |
|
|
27 |
using Trakers.Debug; |
|
|
28 |
|
|
|
29 |
namespace Trakers.Tracking.Postures |
|
|
30 |
{ |
|
|
31 |
public class FallDetector : PostureDetector |
|
|
32 |
{ |
|
|
33 |
static int n = 0; |
|
|
34 |
|
|
|
35 |
public FallDetector(DebugWindow _debug) |
|
|
36 |
: base(_debug) |
|
|
37 |
{ |
|
|
38 |
} |
|
|
39 |
|
|
|
40 |
/* |
|
|
41 |
* Méthode de détection du fall. |
|
|
42 |
*/ |
|
|
43 |
public bool CheckForFall() |
|
|
44 |
{ |
|
|
45 |
//Crée un état local afin de pouvoir analyser s'il y a une posture. |
|
|
46 |
List<Joint> localState = new List<Joint>(currentState); |
|
|
47 |
|
|
|
48 |
//Si les genoux ne sont pas éloignés d'au moins 20cm vers l'avant par rapport aux hanches |
|
|
49 |
//OU si les hanches et la tête ne sont pas au même niveau avec 20 cm d'erreur. |
|
|
50 |
//Alors on ne fait pas un fall. |
|
|
51 |
if (localState[(int)JointType.KneeLeft].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 || |
|
|
53 |
Math.Abs(localState[(int)JointType.HipCenter].Position.Z - localState[(int)JointType.Head].Position.Z) > 0.20) |
|
|
54 |
return false; |
|
|
55 |
return true; |
|
|
56 |
} |
|
|
57 |
} |
|
|
58 |
} |