# HG changeset patch
# User bastiena
# Date 1332148916 -3600
# Node ID d40f84d77db48e03896454fa5d35970a09b4bc64
# Parent f4e52a4c34b3b1f7e137b54d059ea53e11839904
Documentations (readme)
Installer
Deletion of useless comments and code lines
diff -r f4e52a4c34b3 -r d40f84d77db4 .hgignore
--- a/.hgignore Thu Mar 15 13:35:25 2012 +0100
+++ b/.hgignore Mon Mar 19 10:21:56 2012 +0100
@@ -6,3 +6,10 @@
front_processing/src/Trakers_gestures/code/*
front_processing/src/Trakers/code/*
front_processing/extern/TUIO_PROCESSING/library/*
+front_processing/extern/TUIO_JAVA/TuioDemo.jar
+front_processing/extern/TUIO_JAVA/libTUIO.jar
+front_processing/src/Trakers/application.windows/lib/*
+front_processing/src/Trakers_gestures/application.windows/lib/*
+middleware/dist/Output/*
+front_processing/src/Trakers_gestures/application.windows/Trakers_gestures.exe
+front_processing/src/Trakers/application.windows/Trakers.exe
diff -r f4e52a4c34b3 -r d40f84d77db4 front_processing/doc/readme.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/front_processing/doc/readme.txt Mon Mar 19 10:21:56 2012 +0100
@@ -0,0 +1,95 @@
+TraKERS (Tracking using Kinect and Extracting Robust Skeletons) est une interface basée sur la détection de gestures / positions du squelette envoyé par le SDK Microsoft (1.0) de Kinect.
+
+Auteur : Alexandre BASTIEN.
+
+I) TraKERS - Eléments requis :
+
+Dans cette partie, il vous faudra installer Processing, disponible ici : http://processing.org/download/
+
+Vous les trouverez ici si vous le souhaitez : http://www.microsoft.com/en-us/kinectforwindows/develop/release-notes.aspx
+
+II) TraKERS - Structure :
+
+Dans le Front, se trouvent deux exécutables "Trakers" et "Trakers_gestures", respectivement pour le tracé de courbes via les coordonnées des positions des mains récupérées du Middleware et pour l'affichage des gestes détectés. Il aurait été possible de les rassembler en un programme, mais pour des raisons de clarté lors de l'utilisation, j'ai préféré procéder ainsi.
+
+III) TraKERS - Utilisation :
+
+Si le Middleware est lancé, le programme de Front lancé fait office de client, et récupère les notifications envoyées. Détaillons les deux programmes :
+
+A) Trakers
+Comme indiqué plus haut, il reçoit et affiche les coordonnées des mains entrant dans le champ délimité par le Middleware.
+Afin d'indiquer les limites de zone de dessin, un masque noir a été appliqué, et se met à jour.
+Les notifications du client s'affichent en blanc en haut du masque, et indique si une ou deux mains sont détectées.
+Lorsque l'on dessine, une série d'ellipses apparaissent à l'écran, formant des courbes.
+Lorsque deux mains sont détectées, la gauche est rouge et l'autre verte.
+Si une main et une seule est détectée, la courbe sera rouge.
+Si la ou les mains s'approchent et atteignent une certaine proximité, le segment dessiné deviendra bleu à partir de ce moment-là.
+
+B) Trakers_gestures
+Le même masque a été appliqué dans ce programme d'affichage de notifications de gestes indiqués par le Middleware.
+Le programme indique simplement dans la partie supérieure du masque s'il détecte ou non une gesture, et s'il en détecte une, donne le code envoyé par le Middleware.
+
+IV) Fonctionnement :
+
+Les programmes sont découpés en fonctions, afin de rendre leur structure plus cohérente.
+
+Il existe deux fonctions principales sous Processing.
+void setup(), qui permet d'initialiser des variables, la taille de la fenêtre, etc.
+void draw(), qui est raffraichie constamment et sert principalement à dessiner ou faire appel aux fonctions amenées à être appelées toutes les N ms.
+Il est bien entendu possible de dessiner via des fonctions déjà implémentées et prêtes à l'emploi, dont la documentation se trouve ici :
+
+http://processing.org/reference/
+
+Ils reçoivent des messages OSC de la part du Middleware. Ceux-ci sont contenus dans des objets qui sont des TuioCursors (en 3D) pour gérer la position des mains et des TuioStrings (objets personnalisés, ajoutés aux dll client et serveur TUIO).
+
+Dans les programmes, les curseurs 3D sont principalement utilisés pour transmettre les coordonnées X, Y et Z (X et Y étant des pixels, et Z une distance en mètres). Les strings, quant à eux, ne véhiculent que de simples messages textuels.
+
+Ils sont envoyés par des listes présentes dans le client TUIO.
+
+Voici un bout de code expliquant comment obtenir la position des mains :
+
+TuioProcessing tuioClient;
+tuioClient = new TuioProcessing(host, port; //host pourrait être this par défaut et port le numéro du port au format int.
+//On récupère les curseurs.
+Vector tuioCursorList = tuioClient.getTuioCursors();
+//Si aucune main n'est repérée.
+if(tuioCursorList.size() <= 0)
+{
+ //fonction_1();
+}
+//Si une main est repérée.
+else if (tuioCursorList.size() == 1)
+{
+ TuioCursor cursor = (TuioCursor)tuioCursorList.elementAt(0);
+ //fonctionAffiche1Main(cursor);
+}
+//Si c'est les 2.
+else if(tuioCursorList.size() == 2)
+{
+ //fonctionAffiche2Mains(tuioCursorList);
+}
+
+Voici à présent comment extraire les positions d'une main, via un tuioCursor :
+
+//On obtient la liste des points (déplacements) du curseur TUIO.
+Vector pointList = cursor.getPath();
+for (int j=0;j
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff -r f4e52a4c34b3 -r d40f84d77db4 middleware/src/Communication/Server.cs
--- a/middleware/src/Communication/Server.cs Thu Mar 15 13:35:25 2012 +0100
+++ b/middleware/src/Communication/Server.cs Mon Mar 19 10:21:56 2012 +0100
@@ -27,6 +27,9 @@
using System.Windows.Media.Media3D;
using Trakers.Tracking.Events;
using System.Timers;
+using Trakers.Debug;
+using System.Resources;
+using System.Reflection;
namespace Trakers.Communication
{
@@ -34,29 +37,30 @@
{
//Serveur TUIO, provenant de la DLL TuioServer créé par Bespoke.
private TuioServer server;
+ //Affichage de debug.
+ private DebugWindow debug;
//Permet de savoir si un curseur pour la main gauche/droite a été créé.
private bool leftHandCursorCreated;
private bool rightHandCursorCreated;
private bool messageCreated;
private bool gestureLocked;
-
+ //Intervalle minimum entre les gestures.
private int timerElapsing;
-
- System.Timers.Timer _timer;
+ //Timer.
+ private System.Timers.Timer _timer;
+ //Gestionnaire de ressources.
+ private ResourceManager rm;
/*
* Constructeur : On initialise le serveur avec une adresse et un port, au début les curseurs
* ne sont pas créés et on indique au ThreadPool une fonction de callback de manière à vérifier
* s'il reçoit des notifications.
*/
- public Server(String host, int port, int _timerElapsing)
+ public Server(String host, int port, int _timerElapsing, DebugWindow _debug)
{
- //On démarre le serveur TUIO.
- server = new TuioServer(host, port);
- //On initialise le threadPool (appelé toutes les N ms).
- ThreadPool.QueueUserWorkItem(ThreadPoolCallback);
-
+ debug = _debug;
+ rm = new ResourceManager("Trakers.Properties.resources", Assembly.GetExecutingAssembly());
//Au départ, aucune main n'est dans le champ de recherche et aucune gesture n'est détectée.
leftHandCursorCreated = false;
rightHandCursorCreated = false;
@@ -65,10 +69,22 @@
timerElapsing = _timerElapsing;
- //On instancie le timer à N ms.
- _timer = new System.Timers.Timer(timerElapsing);
- //Dès que le timer est expiré, on appelle _timer_Elapsed.
- _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed);
+ try
+ {
+ //On démarre le serveur TUIO.
+ server = new TuioServer(host, port);
+ //On initialise le threadPool (appelé toutes les N ms).
+ ThreadPool.QueueUserWorkItem(ThreadPoolCallback);
+
+ //On instancie le timer à N ms.
+ _timer = new System.Timers.Timer(timerElapsing);
+ //Dès que le timer est expiré, on appelle _timer_Elapsed.
+ _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed);
+ }
+ catch (Exception)
+ {
+ debug.ExceptionLbl.Content = rm.GetString("serverCantStart");
+ }
}
/*
@@ -95,7 +111,6 @@
*/
public void LeftHandTracked(object sender, LeftHandTrackedEventArgs e)
{
- return;
//Si le curseur de la main gauche n'est pas créé, alors on le crée.
if (!leftHandCursorCreated)
{
@@ -114,19 +129,16 @@
*/
public void RightHandTracked(object sender, RightHandTrackedEventArgs e)
{
- return;
//Si le curseur de la main droite n'est pas créé, alors on le crée.
if (!rightHandCursorCreated)
{
server.AddTuioCursor(1, SkeletonPointToPoint3D(e.handJoint.Position));
- //server.AddTuioString(1, "BOO");
rightHandCursorCreated = true;
}
//S'il existe, on le met simplement à jour.
else
{
server.UpdateTuioCursor(1, SkeletonPointToPoint3D(e.handJoint.Position));
- //server.UpdateTuioString(1, "BOO");
}
}
@@ -135,7 +147,6 @@
*/
public void LeftHandQuit(object sender, LeftHandQuitEventArgs e)
{
- return;
//Si le curseur de la main gauche existe, alors on le supprime.
if (leftHandCursorCreated)
{
@@ -149,12 +160,10 @@
*/
public void RightHandQuit(object sender, RightHandQuitEventArgs e)
{
- return;
//Si le curseur de la main droite existe, alors on le supprime.
if (rightHandCursorCreated)
{
server.DeleteTuioCursor(1);
- //server.DeleteTuioString(1);
rightHandCursorCreated = false;
}
}
@@ -191,8 +200,6 @@
else
hand = "BOTH";
- Console.Out.WriteLine(pushPull + "-" + hand);
-
GesturePerformed(pushPull + "-" + hand);
}
@@ -210,7 +217,7 @@
if (!messageCreated)
{
messageCreated = true;
- server.AddTuioString(1, code);
+ server.AddTuioString(2, code);
//On démarre le timer.
_timer.Start();
}
@@ -246,7 +253,7 @@
{
//On débloque la détection de gesture et on supprime l'objet envoyant les messages OSC de gesture.
messageCreated = false;
- server.DeleteTuioString(1);
+ server.DeleteTuioString(2);
}
}
}
diff -r f4e52a4c34b3 -r d40f84d77db4 middleware/src/Debug/DebugParameters.xaml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/middleware/src/Debug/DebugParameters.xaml Mon Mar 19 10:21:56 2012 +0100
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r f4e52a4c34b3 -r d40f84d77db4 middleware/src/Debug/DebugParameters.xaml.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/middleware/src/Debug/DebugParameters.xaml.cs Mon Mar 19 10:21:56 2012 +0100
@@ -0,0 +1,118 @@
+/*
+ * Projet : TraKERS
+ * Module : MIDDLEWARE
+ * Sous-Module : Debug
+ * Classe : DebugParameters
+ *
+ * Auteur : alexandre.bastien@iri.centrepompidou.fr
+ *
+ * Fonctionnalités : Code source attaché à la fenêtre de paramétrage du Middleware.
+ * Celui-ci permet de charger/sauvegarder les paramètres stockés dans KinectMain.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using Trakers.Tracking;
+using System.Reflection;
+using System.Resources;
+
+namespace Trakers.Debug
+{
+ ///
+ /// Interaction logic for DebugParameters.xaml
+ ///
+ public partial class DebugParameters : Window
+ {
+ //Membre d'accès à KinectMain.
+ private KinectMain kinectMain;
+ private ResourceManager rm;
+
+ /*
+ * Constructeur : On ouvre la fenêtre et on charge les paramètres.
+ */
+ public DebugParameters(KinectMain _kinectMain)
+ {
+ rm = new ResourceManager("Trakers.Properties.resources", Assembly.GetExecutingAssembly());
+ kinectMain = _kinectMain;
+ InitializeComponent();
+ getParameters();
+ }
+
+ /*
+ * Permet de charger les paramètres depuis KinectMain et les affiche dans la fenêtre de paramétrage.
+ */
+ public void getParameters()
+ {
+ searchMinDistanceTB.Text = kinectMain.getMinDistHands().ToString();
+ searchMaxDistanceTB.Text = kinectMain.getMaxDistHands().ToString();
+ connexionHostTB.Text = kinectMain.getConnexionHost();
+ connexionPortTB.Text = kinectMain.getConnexionPort().ToString();
+ timerElapsingTB.Text = kinectMain.getTimerElapsing().ToString();
+ }
+
+ /*
+ * Permet de sauvegarder les paramètres de la fenêtre de paramétrage vers KinectMain.
+ */
+ public void setParameters()
+ {
+ try
+ {
+ ExceptionInParametersLbl.Content = "";
+
+ float minDistHands = float.Parse(searchMinDistanceTB.Text);
+ float maxDistHands = float.Parse(searchMaxDistanceTB.Text);
+ int connexionPort = int.Parse(connexionPortTB.Text);
+ int timerElapsing = int.Parse(timerElapsingTB.Text);
+
+ if (maxDistHands <= 0 || minDistHands <= 0 || maxDistHands > 4 || minDistHands > 4 || minDistHands >= maxDistHands || connexionPort < 0 || timerElapsing < 0)
+ {
+ ExceptionInParametersLbl.Content = rm.GetString("loadParametersIncorrect");
+ }
+ else
+ {
+ kinectMain.setMinDistHands(minDistHands);
+ kinectMain.setMaxDistHands(maxDistHands);
+ kinectMain.setConnexionHost(connexionHostTB.Text);
+ kinectMain.setConnexionPort(connexionPort);
+ kinectMain.setTimerElapsing(timerElapsing);
+
+ kinectMain.updateParameters();
+ }
+ }
+ catch (Exception)
+ {
+ //S'il y a eu un problème de parsing (i.e si l'utilisateur a entré une mauvaise valeur),
+ //Alors on affiche l'erreur, puis on recharge les paramètres précédents.
+ ExceptionInParametersLbl.Content = rm.GetString("loadParametersFail");
+ getParameters();
+ }
+ }
+
+ /*
+ * Méthode attachée à l'événement click sur le bouton de validation de la fenêtre de paramétrage.
+ * Les données sont sauvegardées vers KinectMain, puis rechargées dans la fenêtre.
+ */
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ setParameters();
+ }
+
+ /*
+ * Méthode appelée à la fermeture de la fenêtre de paramétrage.
+ */
+ private void Window_Closed(object sender, EventArgs e)
+ {
+
+ }
+ }
+}
diff -r f4e52a4c34b3 -r d40f84d77db4 middleware/src/Debug/DebugWindow.xaml
--- a/middleware/src/Debug/DebugWindow.xaml Thu Mar 15 13:35:25 2012 +0100
+++ b/middleware/src/Debug/DebugWindow.xaml Mon Mar 19 10:21:56 2012 +0100
@@ -2,7 +2,7 @@
Projet : TraKERS
Module : MIDDLEWARE
Sous-Module : Debug
-Classe : Debug
+Classe : DebugWindow
Auteur : alexandre.bastien@iri.centrepompidou.fr
@@ -28,10 +28,20 @@
+
-
+
+
+
+
+
@@ -42,7 +52,7 @@
-
+
@@ -52,21 +62,14 @@
-
-
-
-
-
-
-
-
+
diff -r f4e52a4c34b3 -r d40f84d77db4 middleware/src/Debug/DebugWindow.xaml.cs
--- a/middleware/src/Debug/DebugWindow.xaml.cs Thu Mar 15 13:35:25 2012 +0100
+++ b/middleware/src/Debug/DebugWindow.xaml.cs Mon Mar 19 10:21:56 2012 +0100
@@ -33,11 +33,15 @@
using System.Threading;
using Trakers.Tracking.Events;
using Trakers.Tracking.Gestures;
+using System.Resources;
+using System.Reflection;
namespace Trakers.Debug
{
public partial class DebugWindow : Window
{
+ //Gestionnaire de ressources.
+ private ResourceManager rm;
//Membre permettant d'atteindre la classe KinectMain du sous-module Tracking.
private KinectMain kinectMain;
//Tableau contenant une image en couleurs.
@@ -54,6 +58,7 @@
*/
public DebugWindow(KinectMain main)
{
+ rm = new ResourceManager("Trakers.Properties.resources", Assembly.GetExecutingAssembly());
InitializeComponent();
kinectMain = main;
on = false;
@@ -144,6 +149,9 @@
//Si on a des données dans le tableau et que la kinect est allumée.
if (receivedData && on)
{
+ //Exemples de modifications de l'affichage :
+ //Zombies apocalypse.
+ //Black & White movie.
/*for (int i = 0; i < colorPixelData.Length; i += colorImageFrameData.BytesPerPixel)
{
byte gray = Math.Min(colorPixelData[i], colorPixelData[i + 1]);
@@ -172,12 +180,7 @@
{
DistanceLbl.Content = "Distance : " + distance;
- /*R1.Fill = System.Windows.Media.Brushes.Transparent;
- R2.Fill = System.Windows.Media.Brushes.Transparent;
- R3.Fill = System.Windows.Media.Brushes.Transparent;
- R4.Fill = System.Windows.Media.Brushes.Transparent;*/
-
- /*if (distance > 0 && distance < 1)
+ if (distance > 0 && distance < 1)
{
R1.Fill = System.Windows.Media.Brushes.Red;
R2.Fill = System.Windows.Media.Brushes.DarkGray;
@@ -204,7 +207,7 @@
R2.Fill = System.Windows.Media.Brushes.DarkGray;
R3.Fill = System.Windows.Media.Brushes.DarkGray;
R4.Fill = System.Windows.Media.Brushes.White;
- }*/
+ }
}
/*
@@ -362,5 +365,33 @@
}
}
}
+
+ /*
+ * Méthode associée à l'événement : Ouvrir la fenêtre de paramétrage via le menu.
+ */
+ private void Parameters_Click(object sender, RoutedEventArgs e)
+ {
+ DebugParameters param = new DebugParameters(kinectMain);
+
+ try
+ {
+ param.ShowDialog();
+ }
+ catch (Exception)
+ {
+ ExceptionLbl.Content = rm.GetString("loadParamFail");
+ }
+ }
+
+ /*
+ * Méthode associée à l'événement : Quitter via le menu.
+ */
+ private void Quit_Click(object sender, RoutedEventArgs e)
+ {
+ closing = true;
+ //On éteint la Kinect (pour éviter qu'elle reste allumée même lorsque le programme est éteint).
+ kinectMain.KinectClose();
+ Application.Current.Shutdown();
+ }
}
}
diff -r f4e52a4c34b3 -r d40f84d77db4 middleware/src/Properties/Resources.Designer.cs
--- a/middleware/src/Properties/Resources.Designer.cs Thu Mar 15 13:35:25 2012 +0100
+++ b/middleware/src/Properties/Resources.Designer.cs Mon Mar 19 10:21:56 2012 +0100
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.239
+// Runtime Version:4.0.30319.261
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -86,5 +86,23 @@
return ResourceManager.GetString("loadParametersIncorrect", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to Impossible de charger la fenêtre de paramétrage..
+ ///
+ internal static string loadParamFail {
+ get {
+ return ResourceManager.GetString("loadParamFail", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Impossible de démarrer le serveur TUIO (peut-être host ou port invalide ?)..
+ ///
+ internal static string serverCantStart {
+ get {
+ return ResourceManager.GetString("serverCantStart", resourceCulture);
+ }
+ }
}
}
diff -r f4e52a4c34b3 -r d40f84d77db4 middleware/src/Properties/Resources.resx
--- a/middleware/src/Properties/Resources.resx Thu Mar 15 13:35:25 2012 +0100
+++ b/middleware/src/Properties/Resources.resx Mon Mar 19 10:21:56 2012 +0100
@@ -129,4 +129,12 @@
Paramètres incorrects. Paramètres par défaut.
S'affiche si les paramètres sont incorrects.
+
+ Impossible de charger la fenêtre de paramétrage.
+ S'affiche si l'affichage de la fenêtre de paramétrage a échoué.
+
+
+ Impossible de démarrer le serveur TUIO (peut-être host ou port invalide ?).
+ S'affiche si le serveur ne peut pas démarrer.
+
\ No newline at end of file
diff -r f4e52a4c34b3 -r d40f84d77db4 middleware/src/Tracking/Events/PushListener.cs
--- a/middleware/src/Tracking/Events/PushListener.cs Thu Mar 15 13:35:25 2012 +0100
+++ b/middleware/src/Tracking/Events/PushListener.cs Mon Mar 19 10:21:56 2012 +0100
@@ -26,7 +26,6 @@
*/
public void ShowOnScreen(object o, PushEventArgs e)
{
- //Console.Out.WriteLine("3");
//On l'indique dans le debug.
e.debug.showPush(e);
//e.debug.ExceptionLbl.Content = "SWIPE";
diff -r f4e52a4c34b3 -r d40f84d77db4 middleware/src/Tracking/Gestures/GestureDetector.cs
--- a/middleware/src/Tracking/Gestures/GestureDetector.cs Thu Mar 15 13:35:25 2012 +0100
+++ b/middleware/src/Tracking/Gestures/GestureDetector.cs Mon Mar 19 10:21:56 2012 +0100
@@ -28,11 +28,11 @@
//protected JointCollection previousSkeleton;
//Voici les ID des noeuds d'un squelette : variables magiques en attente de factorisation.
- protected int hipCenterID = 0, spineID = 1, shoulderCenterID = 2, headID = 3;
+ /*protected int hipCenterID = 0, spineID = 1, shoulderCenterID = 2, headID = 3;
protected int shoulderLeftID = 4, elbowLeftID = 5, wristLeftID = 6, handLeftID = 7;
protected int shoulderRightID = 8, elbowRightID = 9, wristRightID = 10, handRightID = 11;
protected int hipLeftID = 12, kneeLeftID = 13, ankleLeftID = 14, footLeftID = 15;
- protected int hipRightID = 16, kneeRightID = 17, ankleRightID = 18, footRightID = 19;
+ protected int hipRightID = 16, kneeRightID = 17, ankleRightID = 18, footRightID = 19;*/
//Elements nécessaires à la reconnaissance du geste :
//Distance du parcours du geste (va dépendre de la distance de l'utilisateur).
diff -r f4e52a4c34b3 -r d40f84d77db4 middleware/src/Tracking/Gestures/JumpDetector.cs
--- a/middleware/src/Tracking/Gestures/JumpDetector.cs Thu Mar 15 13:35:25 2012 +0100
+++ b/middleware/src/Tracking/Gestures/JumpDetector.cs Mon Mar 19 10:21:56 2012 +0100
@@ -8,6 +8,8 @@
*
* Fonctionnalités : Permet de détecter si l'utilisateur a sauté, en se basant sur
* des règles appliquées à la positions des noeuds dans le temps.
+ *
+ * P.S : Cette partie est encore en développement.
*/
using System;
@@ -61,13 +63,14 @@
*/
//La distance de référence est ici la distance entre le milieu du dos et le milieu des épaules.
- refDistance = Math.Abs(localHistory[0][spineID].Position.Y - localHistory[0][shoulderCenterID].Position.Y);
+ refDistance = Math.Abs(localHistory[0][(int)JointType.Spine].Position.Y - localHistory[0][(int)JointType.ShoulderCenter].Position.Y);
//On commence la position pour les indexesToCheck dernières postures (celle à l'index 0 étant la dernière).
int beginIdx = localHistory.Count - indexesToCheck + 1;
int middleIdx = localHistory.Count - indexesToCheck / 2;
- bool middleOK = true, topOfJump = false;
+ //bool middleOK = true
+ bool topOfJump = false;
@@ -75,14 +78,14 @@
for (int i = beginIdx ; i < localHistory.Count ; i++)
{
- if (localHistory[i][handRightID].Position.Y < localHistory[beginIdx][handRightID].Position.Y + refDistance &&
- localHistory[i - 1][handRightID].Position.Y < localHistory[i][handRightID].Position.Y)
+ if (localHistory[i][(int)JointType.HandRight].Position.Y < localHistory[beginIdx][(int)JointType.HandRight].Position.Y + refDistance &&
+ localHistory[i - 1][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.HandRight].Position.Y)
{
topOfJump = true;
//Console.Out.WriteLine("TOP");
}
- if (localHistory[i - 1][handRightID].Position.Y > localHistory[i][handRightID].Position.Y && !topOfJump)
+ if (localHistory[i - 1][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HandRight].Position.Y && !topOfJump)
return false;
//Si la position Y de la main est plus haute que la tête
@@ -91,8 +94,8 @@
//OU si la nouvelle position X de la main est plus éloignée de la distance N par rapport à la première position X
//OU si la nouvelle position Y de la main est plus éloignée de la distance N par rapport à la première position Y
//Alors la main en question ne fait pas de push.
- if (localHistory[i-1][handRightID].Position.Y > localHistory[i][handRightID].Position.Y &&
- topOfJump || localHistory[i - 1][handRightID].Position.Y < localHistory[i][handRightID].Position.Y &&
+ if (localHistory[i - 1][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HandRight].Position.Y &&
+ topOfJump || localHistory[i - 1][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.HandRight].Position.Y &&
!topOfJump)
return false;
}
@@ -109,14 +112,10 @@
//OU si la première position calculée de la main droite/gauche est sur le côté gauche/droit du corps
//Alors on retourne faux.
- //if(
-
//On supprime l'historique local.
- //localHistory.Clear(Math.Abs(localHistory[i-1][handRightID].Position.Y));
-
+
debug.ExceptionLbl.Background = System.Windows.Media.Brushes.Yellow;
- Console.WriteLine("{" + n++ + "}" + "JUMP");
-
+
return false;
}
}
diff -r f4e52a4c34b3 -r d40f84d77db4 middleware/src/Tracking/Gestures/PushDetector.cs
--- a/middleware/src/Tracking/Gestures/PushDetector.cs Thu Mar 15 13:35:25 2012 +0100
+++ b/middleware/src/Tracking/Gestures/PushDetector.cs Mon Mar 19 10:21:56 2012 +0100
@@ -51,10 +51,10 @@
return Hand.NONE;
//La distance de référence est ici la distance entre le milieu du dos et le milieu des épaules.
- refDistance = Math.Abs(localHistory[0][spineID].Position.Y - localHistory[0][shoulderCenterID].Position.Y);
+ refDistance = Math.Abs(localHistory[0][(int)JointType.Spine].Position.Y - localHistory[0][(int)JointType.ShoulderCenter].Position.Y);
//On commence la position pour les indexesToCheck dernières postures (celle à l'index 0 étant la dernière).
- SkeletonPoint startPointLeft = localHistory[localHistory.Count - indexesToCheck][handLeftID].Position;
- SkeletonPoint startPointRight = localHistory[localHistory.Count - indexesToCheck][handRightID].Position;
+ SkeletonPoint startPointLeft = localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandLeft].Position;
+ SkeletonPoint startPointRight = localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandRight].Position;
//Booléens indiquant si le mouvement serait valide pour la main gauche ou droite.
bool leftHandOK = true, rightHandOK = true;
@@ -62,106 +62,55 @@
//De la position p1 Ã pn, on suit l'algorithme.
for (int i = localHistory.Count - indexesToCheck + 1; i < localHistory.Count; i++)
{
- if (localHistory[i][handRightID].Position.Y > localHistory[i][headID].Position.Y)
- debug.R1.Fill = System.Windows.Media.Brushes.Blue;
- else
- debug.R1.Fill = System.Windows.Media.Brushes.DarkGray;
-
- if (localHistory[i][handRightID].Position.Y < localHistory[i][hipCenterID].Position.Y)
- debug.R2.Fill = System.Windows.Media.Brushes.Blue;
- else
- debug.R2.Fill = System.Windows.Media.Brushes.DarkGray;
-
- if (localHistory[i][handRightID].Position.Z < localHistory[i - 1][handRightID].Position.Z)
- debug.R3.Fill = System.Windows.Media.Brushes.Blue;
- else
- debug.R3.Fill = System.Windows.Media.Brushes.DarkGray;
-
- //Console.Out.WriteLine(Math.Abs(localHistory[i][handRightID].Position.X - startPointRight.X) + " " + Math.Abs(localHistory[i][handRightID].Position.Y - startPointRight.Y) + " " + refDistance / 10);
-
- if (Math.Abs(localHistory[i][handRightID].Position.X - startPointRight.X) < refDistance / 5 &&
- Math.Abs(localHistory[i][handRightID].Position.Y - startPointRight.Y) < refDistance / 5)
- debug.R4.Fill = System.Windows.Media.Brushes.Blue;
- else
- debug.R4.Fill = System.Windows.Media.Brushes.DarkGray;
-
//Si la position Y de la main est plus haute que la tête
//OU si la position Y de la main est plus basse que la hanche
//OU si la nouvelle position Z de la main est moins profonde que la précédente
//OU si la nouvelle position X de la main est plus éloignée de la distance N par rapport à la première position X
//OU si la nouvelle position Y de la main est plus éloignée de la distance N par rapport à la première position Y
//Alors la main en question ne fait pas de push.
- if (localHistory[i][handLeftID].Position.Y < localHistory[i][headID].Position.Y ||
- localHistory[i][handLeftID].Position.Y > localHistory[i][hipCenterID].Position.Y ||
- localHistory[i][handLeftID].Position.Z > localHistory[i - 1][handLeftID].Position.Z ||
- Math.Abs(localHistory[i][handLeftID].Position.X - startPointLeft.X) > refDistance / 5 ||
- Math.Abs(localHistory[i][handLeftID].Position.Y - startPointLeft.Y) > refDistance / 5)
+ if (localHistory[i][(int)JointType.HandLeft].Position.Y < localHistory[i][(int)JointType.Head].Position.Y ||
+ localHistory[i][(int)JointType.HandLeft].Position.Y > localHistory[i][(int)JointType.HipCenter].Position.Y ||
+ localHistory[i][(int)JointType.HandLeft].Position.Z > localHistory[i - 1][(int)JointType.HandLeft].Position.Z ||
+ Math.Abs(localHistory[i][(int)JointType.HandLeft].Position.X - startPointLeft.X) > refDistance / 5 ||
+ Math.Abs(localHistory[i][(int)JointType.HandLeft].Position.Y - startPointLeft.Y) > refDistance / 5)
leftHandOK = false;
- if (localHistory[i][handRightID].Position.Y < localHistory[i][headID].Position.Y ||
- localHistory[i][handRightID].Position.Y > localHistory[i][hipCenterID].Position.Y ||
- localHistory[i][handRightID].Position.Z > localHistory[i - 1][handRightID].Position.Z ||
- Math.Abs(localHistory[i][handRightID].Position.X - startPointRight.X) > refDistance / 5 ||
- Math.Abs(localHistory[i][handRightID].Position.Y - startPointRight.Y) > refDistance / 5)
+ if (localHistory[i][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.Head].Position.Y ||
+ localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HipCenter].Position.Y ||
+ localHistory[i][(int)JointType.HandRight].Position.Z > localHistory[i - 1][(int)JointType.HandRight].Position.Z ||
+ Math.Abs(localHistory[i][(int)JointType.HandRight].Position.X - startPointRight.X) > refDistance / 5 ||
+ Math.Abs(localHistory[i][(int)JointType.HandRight].Position.Y - startPointRight.Y) > refDistance / 5)
rightHandOK = false;
if (!leftHandOK && !rightHandOK)
return Hand.NONE;
}
- //Console.Out.WriteLine("OK");
-
- if (Math.Abs(localHistory[localHistory.Count - 1][handRightID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.Z) * 100 > 20)
- debug.R5.Fill = System.Windows.Media.Brushes.Blue;
- else
- debug.R5.Fill = System.Windows.Media.Brushes.DarkGray;
-
- if (localHistory[localHistory.Count - 1][handRightID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X ||
- localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X)
- debug.R6.Fill = System.Windows.Media.Brushes.Blue;
- else
- debug.R6.Fill = System.Windows.Media.Brushes.DarkGray;
-
//Si la distance en Z du geste a été plus courte que la distance N
//Alors on retourne faux.
- //float dist = (localHistory[localHistory.Count - 1][handRightID].Position.X - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X);
-
- //Console.WriteLine(Math.Abs(localHistory[0][handLeftID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.Z) * 100 + " " + refDistance);
-
- if (Math.Abs(localHistory[localHistory.Count - 1][handLeftID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.Z) * 100 < 20)
+ if (Math.Abs(localHistory[localHistory.Count - 1][(int)JointType.HandLeft].Position.Z - localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandLeft].Position.Z) * 100 < 20)
leftHandOK = false;
- if (Math.Abs(localHistory[localHistory.Count - 1][handRightID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.Z) * 100 < 20)
+ if (Math.Abs(localHistory[localHistory.Count - 1][(int)JointType.HandRight].Position.Z - localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandRight].Position.Z) * 100 < 20)
rightHandOK = false;
- /*if(rightHandOK || leftHandOK)
- Console.Out.WriteLine("000000000");*/
-
//Si la dernière position de la main droite/gauche est sur le côté gauche/droit du corps
//OU si la première position calculée de la main droite/gauche est sur le côté gauche/droit du corps
//Alors on retourne faux.
- if (localHistory[localHistory.Count - 1][handLeftID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X ||
- localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X)
+ if (localHistory[localHistory.Count - 1][(int)JointType.HandLeft].Position.X > localHistory[localHistory.Count - 1][(int)JointType.HipCenter].Position.X ||
+ localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandLeft].Position.X > localHistory[localHistory.Count - 1][(int)JointType.HipCenter].Position.X)
leftHandOK = false;
- if (localHistory[localHistory.Count - 1][handRightID].Position.X < localHistory[localHistory.Count - 1][hipCenterID].Position.X ||
- localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X < localHistory[localHistory.Count - 1][hipCenterID].Position.X)
+ if (localHistory[localHistory.Count - 1][(int)JointType.HandRight].Position.X < localHistory[localHistory.Count - 1][(int)JointType.HipCenter].Position.X ||
+ localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandRight].Position.X < localHistory[localHistory.Count - 1][(int)JointType.HipCenter].Position.X)
rightHandOK = false;
- /*if (rightHandOK || leftHandOK)
- Console.Out.WriteLine("11111111111");*/
-
if (!leftHandOK && !rightHandOK)
return Hand.NONE;
- /*if (rightHandOK || leftHandOK)
- Console.Out.WriteLine("================");*/
-
//On supprime l'historique local.
localHistory.Clear();
debug.ExceptionLbl.Background = System.Windows.Media.Brushes.White;
- //Console.WriteLine("PUSH");
- //Console.Read();
-
//Si on est arrivé jusqu'ici, toutes les conditions pour un push ont été remplies.
+
if (leftHandOK && rightHandOK)
return Hand.BOTH;
else if (leftHandOK)
@@ -190,10 +139,10 @@
return Hand.NONE;
//La distance de référence est ici la distance entre le milieu du dos et le milieu des épaules.
- refDistance = Math.Abs(localHistory[0][spineID].Position.Y - localHistory[0][shoulderCenterID].Position.Y);
+ refDistance = Math.Abs(localHistory[0][(int)JointType.Spine].Position.Y - localHistory[0][(int)JointType.ShoulderCenter].Position.Y);
//On commence la position pour les indexesToCheck dernières postures (celle à l'index 0 étant la dernière).
- SkeletonPoint startPointLeft = localHistory[localHistory.Count - indexesToCheck][handLeftID].Position;
- SkeletonPoint startPointRight = localHistory[localHistory.Count - indexesToCheck][handRightID].Position;
+ SkeletonPoint startPointLeft = localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandLeft].Position;
+ SkeletonPoint startPointRight = localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandRight].Position;
//Booléens indiquant si le mouvement serait valide pour la main gauche ou droite.
bool leftHandOK = true, rightHandOK = true;
@@ -207,76 +156,48 @@
//OU si la nouvelle position X de la main est plus éloignée de la distance N par rapport à la première position X
//OU si la nouvelle position Y de la main est plus éloignée de la distance N par rapport à la première position Y
//Alors la main en question ne fait pas de push.
- if (localHistory[i][handLeftID].Position.Y < localHistory[i][headID].Position.Y ||
- localHistory[i][handLeftID].Position.Y > localHistory[i][hipCenterID].Position.Y ||
- localHistory[i][handLeftID].Position.Z < localHistory[i - 1][handLeftID].Position.Z ||
- Math.Abs(localHistory[i][handLeftID].Position.X - startPointLeft.X) > refDistance / 5 ||
- Math.Abs(localHistory[i][handLeftID].Position.Y - startPointLeft.Y) > refDistance / 5)
+ if (localHistory[i][(int)JointType.HandLeft].Position.Y < localHistory[i][(int)JointType.Head].Position.Y ||
+ localHistory[i][(int)JointType.HandLeft].Position.Y > localHistory[i][(int)JointType.HipCenter].Position.Y ||
+ localHistory[i][(int)JointType.HandLeft].Position.Z < localHistory[i - 1][(int)JointType.HandLeft].Position.Z ||
+ Math.Abs(localHistory[i][(int)JointType.HandLeft].Position.X - startPointLeft.X) > refDistance / 5 ||
+ Math.Abs(localHistory[i][(int)JointType.HandLeft].Position.Y - startPointLeft.Y) > refDistance / 5)
leftHandOK = false;
- if (localHistory[i][handRightID].Position.Y < localHistory[i][headID].Position.Y ||
- localHistory[i][handRightID].Position.Y > localHistory[i][hipCenterID].Position.Y ||
- localHistory[i][handRightID].Position.Z < localHistory[i - 1][handRightID].Position.Z ||
- Math.Abs(localHistory[i][handRightID].Position.X - startPointRight.X) > refDistance / 5 ||
- Math.Abs(localHistory[i][handRightID].Position.Y - startPointRight.Y) > refDistance / 5)
+ if (localHistory[i][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.Head].Position.Y ||
+ localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HipCenter].Position.Y ||
+ localHistory[i][(int)JointType.HandRight].Position.Z < localHistory[i - 1][(int)JointType.HandRight].Position.Z ||
+ Math.Abs(localHistory[i][(int)JointType.HandRight].Position.X - startPointRight.X) > refDistance / 5 ||
+ Math.Abs(localHistory[i][(int)JointType.HandRight].Position.Y - startPointRight.Y) > refDistance / 5)
rightHandOK = false;
if (!leftHandOK && !rightHandOK)
return Hand.NONE;
}
- //Console.Out.WriteLine("OK");
-
- if (Math.Abs(localHistory[localHistory.Count - 1][handRightID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.Z) * 100 > 20)
- debug.R5.Fill = System.Windows.Media.Brushes.Blue;
- else
- debug.R5.Fill = System.Windows.Media.Brushes.DarkGray;
-
- if (localHistory[localHistory.Count - 1][handRightID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X ||
- localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X)
- debug.R6.Fill = System.Windows.Media.Brushes.Blue;
- else
- debug.R6.Fill = System.Windows.Media.Brushes.DarkGray;
-
//Si la distance en Z du geste a été plus courte que la distance N
//Alors on retourne faux.
- //float dist = (localHistory[localHistory.Count - 1][handRightID].Position.X - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X);
-
- //Console.WriteLine(Math.Abs(localHistory[0][handLeftID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.Z) * 100 + " " + refDistance);
-
- if (Math.Abs(localHistory[localHistory.Count - 1][handLeftID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.Z) * 100 < 20)
+ if (Math.Abs(localHistory[localHistory.Count - 1][(int)JointType.HandLeft].Position.Z - localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandLeft].Position.Z) * 100 < 20)
leftHandOK = false;
- if (Math.Abs(localHistory[localHistory.Count - 1][handRightID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.Z) * 100 < 20)
+ if (Math.Abs(localHistory[localHistory.Count - 1][(int)JointType.HandRight].Position.Z - localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandRight].Position.Z) * 100 < 20)
rightHandOK = false;
- /*if (rightHandOK || leftHandOK)
- Console.Out.WriteLine("000000000");*/
-
//Si la dernière position de la main droite/gauche est sur le côté gauche/droit du corps
//OU si la première position calculée de la main droite/gauche est sur le côté gauche/droit du corps
//Alors on retourne faux.
- if (localHistory[localHistory.Count - 1][handLeftID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X ||
- localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X)
+ if (localHistory[localHistory.Count - 1][(int)JointType.HandLeft].Position.X > localHistory[localHistory.Count - 1][(int)JointType.HipCenter].Position.X ||
+ localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandLeft].Position.X > localHistory[localHistory.Count - 1][(int)JointType.HipCenter].Position.X)
leftHandOK = false;
- if (localHistory[localHistory.Count - 1][handRightID].Position.X < localHistory[localHistory.Count - 1][hipCenterID].Position.X ||
- localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X < localHistory[localHistory.Count - 1][hipCenterID].Position.X)
+ if (localHistory[localHistory.Count - 1][(int)JointType.HandRight].Position.X < localHistory[localHistory.Count - 1][(int)JointType.HipCenter].Position.X ||
+ localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandRight].Position.X < localHistory[localHistory.Count - 1][(int)JointType.HipCenter].Position.X)
rightHandOK = false;
- /*if (rightHandOK || leftHandOK)
- Console.Out.WriteLine("11111111111");*/
-
if (!leftHandOK && !rightHandOK)
return Hand.NONE;
- /*if (rightHandOK || leftHandOK)
- Console.Out.WriteLine("================");*/
-
//On supprime l'historique local.
localHistory.Clear();
debug.ExceptionLbl.Background = System.Windows.Media.Brushes.Black;
- //Console.WriteLine("PUSH");
- //Console.Read();
-
+
//Si on est arrivé jusqu'ici, toutes les conditions pour un push ont été remplies.
if (leftHandOK && rightHandOK)
return Hand.BOTH;
diff -r f4e52a4c34b3 -r d40f84d77db4 middleware/src/Tracking/Gestures/SwipeDetector.cs
--- a/middleware/src/Tracking/Gestures/SwipeDetector.cs Thu Mar 15 13:35:25 2012 +0100
+++ b/middleware/src/Tracking/Gestures/SwipeDetector.cs Mon Mar 19 10:21:56 2012 +0100
@@ -50,61 +50,37 @@
return false;
//La distance de référence est ici la distance entre le milieu du dos et le milieu des épaules.
- refDistance = Math.Abs(localHistory[0][spineID].Position.Y - localHistory[0][shoulderCenterID].Position.Y);
+ refDistance = Math.Abs(localHistory[0][(int)JointType.Spine].Position.Y - localHistory[0][(int)JointType.ShoulderCenter].Position.Y);
//On commence la position pour les indexesToCheck dernières postures (celle à l'index 0 étant la dernière).
- startPoint = localHistory[localHistory.Count - indexesToCheck][handRightID].Position;
+ startPoint = localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandRight].Position;
//De la position p1 Ã pn, on suit l'algorithme.
for (int i = localHistory.Count - indexesToCheck + 1; i < localHistory.Count; i++)
{
- //Debug temporaire pour vérifier la validité de certaines contraintes durant la gesture.
- /*if (localHistory[i][handRightID].Position.Y > localHistory[i][headID].Position.Y)
- debug.R1.Fill = System.Windows.Media.Brushes.Blue;
- else
- debug.R1.Fill = System.Windows.Media.Brushes.DarkGray;
-
- if(localHistory[i][handRightID].Position.Y < localHistory[i][hipCenterID].Position.Y)
- debug.R2.Fill = System.Windows.Media.Brushes.Blue;
- else
- debug.R2.Fill = System.Windows.Media.Brushes.DarkGray;
-
- if(localHistory[i][handRightID].Position.X < localHistory[i - 1][handRightID].Position.X)
- debug.R3.Fill = System.Windows.Media.Brushes.Blue;
- else
- debug.R3.Fill = System.Windows.Media.Brushes.DarkGray;
-
- if(Math.Abs(localHistory[i][handRightID].Position.Y - startPoint.Y) < refDistance/2)
- debug.R4.Fill = System.Windows.Media.Brushes.Blue;
- else
- debug.R4.Fill = System.Windows.Media.Brushes.DarkGray;*/
-
//Si la position Y de la main est plus haute que la tête
//OU si la position Y de la main est plus basse que la hanche
//OU si la nouvelle position X de la main est à droite de la précédente
//OU si la nouvelle position Y de la main est plus éloignée de la distance N par rapport à la première position Y
//Alors on retourne faux.
- if (localHistory[i][handRightID].Position.Y < localHistory[i][headID].Position.Y ||
- localHistory[i][handRightID].Position.Y > localHistory[i][hipCenterID].Position.Y ||
- localHistory[i][handRightID].Position.X > localHistory[i - 1][handRightID].Position.X ||
- Math.Abs(localHistory[i][handRightID].Position.Y - startPoint.Y) > refDistance/2)
+ if (localHistory[i][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.Head].Position.Y ||
+ localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HipCenter].Position.Y ||
+ localHistory[i][(int)JointType.HandRight].Position.X > localHistory[i - 1][(int)JointType.HandRight].Position.X ||
+ Math.Abs(localHistory[i][(int)JointType.HandRight].Position.Y - startPoint.Y) > refDistance / 2)
return false;
}
//Si la distance horizontale du geste a été plus courte que la distance N
//Alors on retourne faux.
- //float dist = (localHistory[localHistory.Count - 1][handRightID].Position.X - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X);
-
- if (Math.Abs(localHistory[0][handRightID].Position.X - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X) < refDistance/2)
+ if (Math.Abs(localHistory[0][(int)JointType.HandRight].Position.X - localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandRight].Position.X) < refDistance / 2)
return false;
//Si la dernière position de la main droite est sur le côté droit du corps
//OU si la première position calculée de la main droite est sur le côté gauche du corps
//Alors on retourne faux.
- if(localHistory[localHistory.Count - 1][handRightID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X ||
- localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X < localHistory[localHistory.Count - 1][hipCenterID].Position.X)
+ if (localHistory[localHistory.Count - 1][(int)JointType.HandRight].Position.X > localHistory[localHistory.Count - 1][(int)JointType.HipCenter].Position.X ||
+ localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandRight].Position.X < localHistory[localHistory.Count - 1][(int)JointType.HipCenter].Position.X)
return false;
- //System.Console.Out.WriteLine(Math.Abs(localHistory[0][handRightID].Position.X - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X) + " < " + refDistance/2);
//On supprime l'historique local.
localHistory.Clear();
//Si on est arrivé jusqu'ici, toutes les conditions pour un swipe left ont été remplies.
@@ -129,61 +105,37 @@
return false;
//La distance de référence est ici la distance entre le milieu du dos et le milieu des épaules.
- refDistance = Math.Abs(localHistory[0][spineID].Position.Y - localHistory[0][shoulderCenterID].Position.Y);
+ refDistance = Math.Abs(localHistory[0][(int)JointType.Spine].Position.Y - localHistory[0][(int)JointType.ShoulderCenter].Position.Y);
//On commence la position pour les indexesToCheck dernières postures (celle à l'index 0 étant la dernière).
- startPoint = localHistory[localHistory.Count - indexesToCheck][handLeftID].Position;
+ startPoint = localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandLeft].Position;
//De la position p1 Ã pn, on suit l'algorithme.
for (int i = localHistory.Count - indexesToCheck + 1; i < localHistory.Count; i++)
{
- //Debug temporaire pour vérifier la validité de certaines contraintes durant la gesture.
- /*if (localHistory[i][handLeftID].Position.Y > localHistory[i][headID].Position.Y)
- debug.R1.Fill = System.Windows.Media.Brushes.Cyan;
- else
- debug.R1.Fill = System.Windows.Media.Brushes.DarkGray;
-
- if (localHistory[i][handLeftID].Position.Y < localHistory[i][hipCenterID].Position.Y)
- debug.R2.Fill = System.Windows.Media.Brushes.Cyan;
- else
- debug.R2.Fill = System.Windows.Media.Brushes.DarkGray;
-
- if (localHistory[i][handLeftID].Position.X > localHistory[i - 1][handLeftID].Position.X)
- debug.R3.Fill = System.Windows.Media.Brushes.Cyan;
- else
- debug.R3.Fill = System.Windows.Media.Brushes.DarkGray;
-
- if (Math.Abs(localHistory[i][handLeftID].Position.Y - startPoint.Y) < refDistance / 2)
- debug.R4.Fill = System.Windows.Media.Brushes.Cyan;
- else
- debug.R4.Fill = System.Windows.Media.Brushes.DarkGray;*/
-
//Si la position Y de la main est plus haute que la tête
//OU si la position Y de la main est plus basse que la hanche
//OU si la nouvelle position X de la main est à gauche de la précédente
//OU si la nouvelle position Y de la main est plus éloignée de la distance N par rapport à la première position Y
//Alors on retourne faux.
- if (localHistory[i][handLeftID].Position.Y < localHistory[i][headID].Position.Y ||
- localHistory[i][handLeftID].Position.Y > localHistory[i][hipCenterID].Position.Y ||
- localHistory[i][handLeftID].Position.X < localHistory[i - 1][handLeftID].Position.X ||
- Math.Abs(localHistory[i][handLeftID].Position.Y - startPoint.Y) > refDistance / 2)
+ if (localHistory[i][(int)JointType.HandLeft].Position.Y < localHistory[i][(int)JointType.Head].Position.Y ||
+ localHistory[i][(int)JointType.HandLeft].Position.Y > localHistory[i][(int)JointType.HipCenter].Position.Y ||
+ localHistory[i][(int)JointType.HandLeft].Position.X < localHistory[i - 1][(int)JointType.HandLeft].Position.X ||
+ Math.Abs(localHistory[i][(int)JointType.HandLeft].Position.Y - startPoint.Y) > refDistance / 2)
return false;
}
//Si la distance horizontale du geste a été plus courte que la distance N
//Alors on retourne faux.
- //float dist = (localHistory[localHistory.Count - 1][handLeftID].Position.X - localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.X);
-
- if (Math.Abs(localHistory[0][handLeftID].Position.X - localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.X) < refDistance / 2)
+ if (Math.Abs(localHistory[0][(int)JointType.HandLeft].Position.X - localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandLeft].Position.X) < refDistance / 2)
return false;
//Si la dernière position de la main droite est sur le côté gauche du corps
//OU si la première position calculée de la main droite est sur le côté droit du corps
//Alors on retourne faux.
- if (localHistory[localHistory.Count - 1][handLeftID].Position.X < localHistory[localHistory.Count - 1][hipCenterID].Position.X ||
- localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X)
+ if (localHistory[localHistory.Count - 1][(int)JointType.HandLeft].Position.X < localHistory[localHistory.Count - 1][(int)JointType.HipCenter].Position.X ||
+ localHistory[localHistory.Count - indexesToCheck][(int)JointType.HandLeft].Position.X > localHistory[localHistory.Count - 1][(int)JointType.HipCenter].Position.X)
return false;
- //System.Console.Out.WriteLine(Math.Abs(localHistory[0][handLeftID].Position.X - localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.X) + " < " + refDistance / 2);
//On supprime l'historique local.
localHistory.Clear();
//Si on est arrivé jusqu'ici, toutes les conditions pour un swipe right ont été remplies.
diff -r f4e52a4c34b3 -r d40f84d77db4 middleware/src/Tracking/KinectMain.cs
--- a/middleware/src/Tracking/KinectMain.cs Thu Mar 15 13:35:25 2012 +0100
+++ b/middleware/src/Tracking/KinectMain.cs Mon Mar 19 10:21:56 2012 +0100
@@ -96,14 +96,7 @@
public static event PushHandler PushEvent;
//L'événement jump.
public static event JumpHandler JumpEvent;
-
- //Voici les ID des noeuds d'un squelette.
- public int hipCenterID = 0, spineID = 1, shoulderCenterID = 2, headID = 3;
- public int shoulderLeftID = 4, elbowLeftID = 5, wristLeftID = 6, handLeftID = 7;
- public int shoulderRightID = 8, elbowRightID = 9, wristRightID = 10, handRightID = 11;
- public int hipLeftID = 12, kneeLeftID = 13, ankleLeftID = 14, footLeftID = 15;
- public int hipRightID = 16, kneeRightID = 17, ankleRightID = 18, footRightID = 19;
-
+
private string connexionHost;
private int connexionPort;
@@ -114,9 +107,8 @@
*/
public KinectMain()
{
- //Si on n'a pas fait appel au gestionnaire de ressources avant, on le fait là .
- if(rm == null)
- rm = new ResourceManager("Trakers.Properties.resources", Assembly.GetExecutingAssembly());
+ //On fait appel au gestionnaire de ressources.
+ rm = new ResourceManager("Trakers.Properties.resources", Assembly.GetExecutingAssembly());
//On crée la fenêtre de debug.
debug = new Debug.DebugWindow(this);
@@ -220,7 +212,7 @@
JumpEvent += new JumpHandler(jumpListener.ShowOnScreen);
//On connecte le serveur à l'adresse locale sur le port 80.
- server = new Server(connexionHost, connexionPort, timerElapsing);
+ server = new Server(connexionHost, connexionPort, timerElapsing, debug);
}
/*
@@ -330,35 +322,35 @@
if (first.TrackingState == SkeletonTrackingState.Tracked)
{
//Ensemble des noeuds du squelette.
- Joint hipCenter = getJoint(first, hipCenterID), spine = getJoint(first, spineID), shoulderCenter = getJoint(first, shoulderCenterID), head = getJoint(first, headID);
- Joint shoulderLeft = getJoint(first, shoulderLeftID), elbowLeft = getJoint(first, elbowLeftID), wristLeft = getJoint(first, wristLeftID), handLeft = getJoint(first, handLeftID);
- Joint shoulderRight = getJoint(first, shoulderRightID), elbowRight = getJoint(first, elbowRightID), wristRight = getJoint(first, wristRightID), handRight = getJoint(first, handRightID);
- Joint hipLeft = getJoint(first, hipLeftID), kneeLeft = getJoint(first, kneeLeftID), ankleLeft = getJoint(first, ankleLeftID), footLeft = getJoint(first, footLeftID);
- Joint hipRight = getJoint(first, hipRightID), kneeRight = getJoint(first, kneeRightID), ankleRight = getJoint(first, ankleRightID), footRight = getJoint(first, footRightID);
+ Joint hipCenter = getJoint(first, JointType.HipCenter), spine = getJoint(first, JointType.Spine), shoulderCenter = getJoint(first, JointType.ShoulderCenter), head = getJoint(first, JointType.Head);
+ Joint shoulderLeft = getJoint(first, JointType.ShoulderLeft), elbowLeft = getJoint(first, JointType.ElbowLeft), wristLeft = getJoint(first, JointType.WristLeft), handLeft = getJoint(first, JointType.HandLeft);
+ Joint shoulderRight = getJoint(first, JointType.ShoulderRight), elbowRight = getJoint(first, JointType.ElbowRight), wristRight = getJoint(first, JointType.WristRight), handRight = getJoint(first, JointType.HandRight);
+ Joint hipLeft = getJoint(first, JointType.HipLeft), kneeLeft = getJoint(first, JointType.KneeLeft), ankleLeft = getJoint(first, JointType.AnkleLeft), footLeft = getJoint(first, JointType.FootLeft);
+ Joint hipRight = getJoint(first, JointType.HipRight), kneeRight = getJoint(first, JointType.KneeRight), ankleRight = getJoint(first, JointType.AnkleRight), footRight = getJoint(first, JointType.FootRight);
//On construit l'historique des postures.
List joints = new List();
joints.Clear();
- joints.Insert(hipCenterID, hipCenter);
- joints.Insert(spineID, spine);
- joints.Insert(shoulderCenterID, shoulderCenter);
- joints.Insert(headID, head);
- joints.Insert(shoulderLeftID, shoulderLeft);
- joints.Insert(elbowLeftID, elbowLeft);
- joints.Insert(wristLeftID, wristLeft);
- joints.Insert(handLeftID, handLeft);
- joints.Insert(shoulderRightID, shoulderRight);
- joints.Insert(elbowRightID, elbowRight);
- joints.Insert(wristRightID, wristRight);
- joints.Insert(handRightID, handRight);
- joints.Insert(hipLeftID, hipLeft);
- joints.Insert(kneeLeftID, kneeLeft);
- joints.Insert(ankleLeftID, ankleLeft);
- joints.Insert(footLeftID, footLeft);
- joints.Insert(hipRightID, hipRight);
- joints.Insert(kneeRightID, kneeRight);
- joints.Insert(ankleRightID, ankleRight);
- joints.Insert(footRightID, footRight);
+ joints.Insert((int)JointType.HipCenter, hipCenter);
+ joints.Insert((int)JointType.Spine, spine);
+ joints.Insert((int)JointType.ShoulderCenter, shoulderCenter);
+ joints.Insert((int)JointType.Head, head);
+ joints.Insert((int)JointType.ShoulderLeft, shoulderLeft);
+ joints.Insert((int)JointType.ElbowLeft, elbowLeft);
+ joints.Insert((int)JointType.WristLeft, wristLeft);
+ joints.Insert((int)JointType.HandLeft, handLeft);
+ joints.Insert((int)JointType.ShoulderRight, shoulderRight);
+ joints.Insert((int)JointType.ElbowRight, elbowRight);
+ joints.Insert((int)JointType.WristRight, wristRight);
+ joints.Insert((int)JointType.HandRight, handRight);
+ joints.Insert((int)JointType.HipLeft, hipLeft);
+ joints.Insert((int)JointType.KneeLeft, kneeLeft);
+ joints.Insert((int)JointType.AnkleLeft, ankleLeft);
+ joints.Insert((int)JointType.FootLeft, footLeft);
+ joints.Insert((int)JointType.HipRight, hipRight);
+ joints.Insert((int)JointType.KneeRight, kneeRight);
+ joints.Insert((int)JointType.AnkleRight, ankleRight);
+ joints.Insert((int)JointType.FootRight, footRight);
GestureDetector.UpdateSkeletonHistory(joints);
//On obtient sa distance à la Kinect.
@@ -437,9 +429,9 @@
/*
* Change l'échelle des coordonnées d'un noeud pour qu'en X et Y il corresponde à la résolution et en Z à la distance à la Kinect.
*/
- public Joint getJoint(Skeleton ske, int jointID)
+ public Joint getJoint(Skeleton ske, JointType jointID)
{
- return Coding4Fun.Kinect.Wpf.SkeletalExtensions.ScaleTo(ske.Joints.ElementAt(jointID), 600, 400, 0.75f, 0.75f);
+ return Coding4Fun.Kinect.Wpf.SkeletalExtensions.ScaleTo(ske.Joints[jointID], 600, 400, 0.75f, 0.75f);
}
/*
@@ -516,26 +508,6 @@
maxDistHands = (float)double.Parse(ConfigurationManager.AppSettings["searchMaxDistance"]);
connexionHost = ConfigurationManager.AppSettings["connexionHost"];
connexionPort = int.Parse(ConfigurationManager.AppSettings["connexionPort"]);
- hipCenterID = int.Parse(ConfigurationManager.AppSettings["hipCenterID"]);
- spineID = int.Parse(ConfigurationManager.AppSettings["spineID"]);
- shoulderCenterID = int.Parse(ConfigurationManager.AppSettings["shoulderCenterID"]);
- headID = int.Parse(ConfigurationManager.AppSettings["headID"]);
- shoulderLeftID = int.Parse(ConfigurationManager.AppSettings["shoulderLeftID"]);
- elbowLeftID = int.Parse(ConfigurationManager.AppSettings["elbowLeftID"]);
- wristLeftID = int.Parse(ConfigurationManager.AppSettings["wristLeftID"]);
- handLeftID = int.Parse(ConfigurationManager.AppSettings["handLeftID"]);
- shoulderRightID = int.Parse(ConfigurationManager.AppSettings["shoulderRightID"]);
- elbowRightID = int.Parse(ConfigurationManager.AppSettings["elbowRightID"]);
- wristRightID = int.Parse(ConfigurationManager.AppSettings["wristRightID"]);
- handRightID = int.Parse(ConfigurationManager.AppSettings["handRightID"]);
- hipLeftID = int.Parse(ConfigurationManager.AppSettings["hipLeftID"]);
- kneeLeftID = int.Parse(ConfigurationManager.AppSettings["kneeLeftID"]);
- ankleLeftID = int.Parse(ConfigurationManager.AppSettings["ankleLeftID"]);
- footLeftID = int.Parse(ConfigurationManager.AppSettings["footLeftID"]);
- hipRightID = int.Parse(ConfigurationManager.AppSettings["hipRightID"]);
- kneeRightID = int.Parse(ConfigurationManager.AppSettings["kneeRightID"]);
- ankleRightID = int.Parse(ConfigurationManager.AppSettings["ankleRightID"]);
- footRightID = int.Parse(ConfigurationManager.AppSettings["footRightID"]);
timerElapsing = int.Parse(ConfigurationManager.AppSettings["timerElapsing"]);
}
catch (Exception)
@@ -550,5 +522,74 @@
}
return true;
}
+
+ /*
+ * Met à jour les nouveaux paramètres dans la configuration.
+ */
+ public void updateParameters()
+ {
+ //On récupère la config.
+ Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
+ //On met à jour.
+ config.AppSettings.Settings.Remove("searchMinDistance");
+ config.AppSettings.Settings.Add("searchMinDistance", minDistHands.ToString());
+ config.AppSettings.Settings.Remove("searchMaxDistance");
+ config.AppSettings.Settings.Add("searchMaxDistance", maxDistHands.ToString());
+ config.AppSettings.Settings.Remove("connexionHost");
+ config.AppSettings.Settings.Add("connexionHost", connexionHost);
+ config.AppSettings.Settings.Remove("connexionPort");
+ config.AppSettings.Settings.Add("connexionPort", connexionPort.ToString());
+ config.AppSettings.Settings.Remove("timerElapsing");
+ config.AppSettings.Settings.Add("timerElapsing", timerElapsing.ToString());
+
+ //Sauvegarde la configuration.
+ config.Save(ConfigurationSaveMode.Modified);
+ ConfigurationManager.RefreshSection("appSettings");
+ }
+
+ /*
+ * Getters et setters des paramètres du Middleware.
+ */
+ public void setMinDistHands(float min)
+ {
+ minDistHands = min;
+ }
+ public void setMaxDistHands(float max)
+ {
+ maxDistHands = max;
+ }
+ public void setConnexionHost(String host)
+ {
+ connexionHost = host;
+ }
+ public void setConnexionPort(int port)
+ {
+ connexionPort = port;
+ }
+ public void setTimerElapsing(int time)
+ {
+ timerElapsing = time;
+ }
+
+ public float getMinDistHands()
+ {
+ return minDistHands;
+ }
+ public float getMaxDistHands()
+ {
+ return maxDistHands;
+ }
+ public String getConnexionHost()
+ {
+ return connexionHost;
+ }
+ public int getConnexionPort()
+ {
+ return connexionPort;
+ }
+ public int getTimerElapsing()
+ {
+ return timerElapsing;
+ }
}
}
diff -r f4e52a4c34b3 -r d40f84d77db4 middleware/src/Trakers.csproj
--- a/middleware/src/Trakers.csproj Thu Mar 15 13:35:25 2012 +0100
+++ b/middleware/src/Trakers.csproj Mon Mar 19 10:21:56 2012 +0100
@@ -6,7 +6,7 @@
8.0.30703
2.0
{09EF8613-2F1B-4F1D-B6B1-22938EBB529A}
- Exe
+ WinExe
Properties
Trakers
Trakers
@@ -77,6 +77,9 @@
+
+ DebugParameters.xaml
+
DebugWindow.xaml
@@ -136,6 +139,10 @@
+
+ Designer
+ MSBuild:Compile
+
MSBuild:Compile
Designer