|
17
|
1 |
/* |
|
|
2 |
* This file is part of the TraKERS\Middleware package. |
|
|
3 |
* |
|
|
4 |
* (c) IRI <http://www.iri.centrepompidou.fr/> |
|
|
5 |
* |
|
27
|
6 |
* For the full copyright and license information, please view the LICENSE |
|
17
|
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 : CrossDetector |
|
|
15 |
* |
|
|
16 |
* Auteur : alexandre.bastien@iri.centrepompidou.fr |
|
|
17 |
* |
|
|
18 |
* Fonctionnalités : Permet de détecter si l'utilisateur a croisé les bras en X, 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 CrossDetector : PostureDetector |
|
|
32 |
{ |
|
|
33 |
public CrossDetector(DebugWindow _debug) : base(_debug) |
|
|
34 |
{ |
|
|
35 |
} |
|
|
36 |
|
|
|
37 |
/* |
|
|
38 |
* Méthode de détection du penché. |
|
|
39 |
*/ |
|
|
40 |
public bool CheckForCross() |
|
|
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 |
//La distance de référence est ici la distance entre le milieu du dos et le milieu des épaules. |
|
|
46 |
refDistance = Math.Abs(localState[(int)JointType.Spine].Position.Y - localState[(int)JointType.ShoulderCenter].Position.Y); |
|
|
47 |
|
|
23
|
48 |
/*if (localState[(int)JointType.HandLeft].Position.Y < localState[(int)JointType.ElbowLeft].Position.Y - refDistance / 2) |
|
17
|
49 |
debug.onR0(true); |
|
|
50 |
else |
|
|
51 |
debug.onR0(false); |
|
|
52 |
if (localState[(int)JointType.HandRight].Position.Y < localState[(int)JointType.ElbowRight].Position.Y - refDistance / 2) |
|
|
53 |
debug.onR1(true); |
|
|
54 |
else |
|
|
55 |
debug.onR1(false); |
|
|
56 |
if (localState[(int)JointType.ElbowLeft].Position.X + refDistance / 2 < localState[(int)JointType.ElbowRight].Position.X) |
|
|
57 |
debug.onR2(true); |
|
|
58 |
else |
|
|
59 |
debug.onR2(false); |
|
|
60 |
if (localState[(int)JointType.HandLeft].Position.X + refDistance / 2 > localState[(int)JointType.HandRight].Position.X) |
|
|
61 |
debug.onR3(true); |
|
|
62 |
else |
|
23
|
63 |
debug.onR3(false);*/ |
|
17
|
64 |
//Si la position Y de la main gauche n'est pas plus haute de la distance de référence que le coude gauche |
|
|
65 |
//OU si la position Y de la main droite n'est pas plus haute de la distance de référence que le coude droit |
|
|
66 |
//OU si la position X du coude gauche n'est pas plus à gauche de la distance de référence/2 que le coude droit |
|
|
67 |
//OU si la position X de la main gauche n'est pas plus à droite de la distance de référence/4 que la main gauche. |
|
|
68 |
//Alors l'utilisateur ne croise pas les bras. |
|
|
69 |
/*if (localState[(int)JointType.HandRight].Position.Y > localState[(int)JointType.ElbowRight].Position.Y + refDistance || |
|
|
70 |
localState[(int)JointType.HandRight].Position.Y > localState[(int)JointType.HipCenter].Position.Y || |
|
|
71 |
localState[(int)JointType.HandRight].Position.Y > localState[(int)JointType.WristRight].Position.Y + refDistance / 4) |
|
|
72 |
return false; |
|
|
73 |
return true;*/ |
|
|
74 |
|
|
|
75 |
return false; |
|
|
76 |
} |
|
|
77 |
} |
|
|
78 |
} |