|
17
|
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_MIDDLEWARE |
|
|
7 |
* file that was distributed with this source code. |
|
|
8 |
*/ |
|
|
9 |
|
|
|
10 |
/* |
|
|
11 |
* Projet : TraKERS |
|
|
12 |
* Module : MIDDLEWARE |
|
|
13 |
* Sous-Module : Tracking/Postures |
|
|
14 |
* Classe : BendDetector |
|
|
15 |
* |
|
|
16 |
* Auteur : alexandre.bastien@iri.centrepompidou.fr |
|
|
17 |
* |
|
|
18 |
* Fonctionnalités : Permet de détecter si l'utilisateur s'est penché, en se basant sur |
|
|
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 BendDetector : PostureDetector |
|
|
32 |
{ |
|
|
33 |
public BendDetector(DebugWindow _debug) : base(_debug) |
|
|
34 |
{ |
|
|
35 |
} |
|
|
36 |
|
|
|
37 |
/* |
|
|
38 |
* Méthode de détection du penché. |
|
|
39 |
*/ |
|
|
40 |
public bool CheckForBend() |
|
|
41 |
{ |
|
|
42 |
//Crée un état local afin de pouvoir analyser s'il y a une posture. |
|
|
43 |
List<Joint> localState = new List<Joint>(currentState); |
|
|
44 |
|
|
|
45 |
/*if (localState[(int)JointType.Head].Position.Z + 0.10 < localState[(int)JointType.ShoulderCenter].Position.Z) |
|
|
46 |
debug.onR0(true); |
|
|
47 |
else |
|
|
48 |
debug.onR0(false); |
|
|
49 |
if (localState[(int)JointType.ShoulderCenter].Position.Z + 0.20 < localState[(int)JointType.HipCenter].Position.Z) |
|
|
50 |
debug.onR1(true); |
|
|
51 |
else |
|
|
52 |
debug.onR1(false); |
|
|
53 |
if (Math.Abs(localState[(int)JointType.HipCenter].Position.Z - localState[(int)JointType.KneeRight].Position.Z) < 0.20) |
|
|
54 |
debug.onR2(true); |
|
|
55 |
else |
|
|
56 |
debug.onR2(false);*/ |
|
|
57 |
|
|
|
58 |
//Si la tête n'est pas plus proche d'au moins 20cm que les épaules |
|
|
59 |
//OU si les épaules ne sont pas plus proches d'au moins 20 cm que les hanches |
|
|
60 |
//OU si les hanches et les genoux ne sont pas au même niveau avec 20 cm d'erreur. |
|
|
61 |
//Alors on ne s'est pas penché. |
|
|
62 |
if (localState[(int)JointType.Head].Position.Z + 0.10 >= localState[(int)JointType.ShoulderCenter].Position.Z || |
|
|
63 |
localState[(int)JointType.ShoulderCenter].Position.Z + 0.20 >= localState[(int)JointType.HipCenter].Position.Z || |
|
|
64 |
Math.Abs(localState[(int)JointType.HipCenter].Position.Z - localState[(int)JointType.KneeRight].Position.Z) > 0.20) |
|
|
65 |
return false; |
|
|
66 |
return true; |
|
|
67 |
} |
|
|
68 |
} |
|
|
69 |
} |