# HG changeset patch
# User bastiena
# Date 1340290376 -7200
# Node ID 37ebedd84755cdcfbcab3c3bedcc7d12adeb2e3c
# Parent 25e71ada2a6db5d2b191a36b477acbcd16d7c376
MID :
2 new gestures : fall & jump
config in a txt file
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/Communication/TUIOServer.cs
--- a/middleware/Communication/TUIOServer.cs Wed May 30 10:22:46 2012 +0200
+++ b/middleware/Communication/TUIOServer.cs Thu Jun 21 16:52:56 2012 +0200
@@ -171,7 +171,7 @@
public void GesturePerformed(String code)
{
//Si le code vient d'être envoyé, on passe.
- if (lastCode.Equals(code))
+ if (lastCode.Equals(code) && !gestureLocked)
return;
lastCode = code;
//Si une gesture a été effectuée, on bloque un certain temps.
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/Communication/WSServer.cs
--- a/middleware/Communication/WSServer.cs Wed May 30 10:22:46 2012 +0200
+++ b/middleware/Communication/WSServer.cs Thu Jun 21 16:52:56 2012 +0200
@@ -43,18 +43,19 @@
//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 gesturesMessageCreated, modeMessageCreated;
private bool gestureLocked, modLocked;
//Intervalle minimum entre les gestures.
private int timerElapsing;
- //Timer.
- private System.Timers.Timer _timer;
+ //Timers.
+ private System.Timers.Timer _gesturesTimer;
+ private System.Timers.Timer _userPositionTimer;
//Dernier code envoyé.
private String lastCode;
//Messages envoyés en WS.
- private String rightHandMessage, leftHandMessage, gestureMessage;
+ private String rightHandMessage, leftHandMessage, gesturesMessage, modeMessage;
//Messages précédents
- private String prevRightHandMessage, prevLeftHandMessage, prevGestureMessage;
+ private String prevRightHandMessage, prevLeftHandMessage, prevGestureMessage, prevModeMessage;
/*
* Constructeur : On initialise le serveur avec une adresse et un port, au début les curseurs
@@ -70,14 +71,15 @@
//Au départ, aucune main n'est dans le champ de recherche et aucune gesture n'est détectée.
leftHandCursorCreated = false;
rightHandCursorCreated = false;
- messageCreated = false;
+ gesturesMessageCreated = false;
+ modeMessageCreated = false;
gestureLocked = false;
modLocked = false;
lastCode = "";
- timerElapsing = _timerElapsing;
+ timerElapsing = 500;// _timerElapsing;
- rightHandMessage = leftHandMessage = gestureMessage = "";
+ rightHandMessage = leftHandMessage = gesturesMessage = modeMessage = "";
//On démarre le serveur WebSocket.
server.Start(socket =>
@@ -103,9 +105,11 @@
ThreadPool.QueueUserWorkItem(ThreadPoolCallback);
//On instancie le timer à N ms.
- _timer = new System.Timers.Timer(timerElapsing);
+ _gesturesTimer = new System.Timers.Timer(timerElapsing);
+ _userPositionTimer = new System.Timers.Timer(timerElapsing/5);
//Dès que le timer est expiré, on appelle _timer_Elapsed.
- _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed);
+ _gesturesTimer.Elapsed += new ElapsedEventHandler(_gesturesTimer_Elapsed);
+ _userPositionTimer.Elapsed += new ElapsedEventHandler(_userPositionTimer_Elapsed);
/*var input = Console.ReadLine();
while (input != "exit")
@@ -121,14 +125,29 @@
/*
* Méthode appelée à l'expiration du timer pour les gestures et modes.
*/
- public void _timer_Elapsed(object sender, ElapsedEventArgs e)
+ public void _gesturesTimer_Elapsed(object sender, ElapsedEventArgs e)
{
//On débloque la détection de gesture.
gestureLocked = false;
//On débloque la notification de nouveau mode.
- modLocked = false;
+ //modLocked = false;
+ lastCode = "";
//On arrête le timer.
- _timer.Stop();
+ _gesturesTimer.Stop();
+ }
+
+ /*
+ * Méthode appelée à l'expiration du timer pour les positions d'utilisateur.
+ */
+ public void _userPositionTimer_Elapsed(object sender, ElapsedEventArgs e)
+ {
+ //On débloque la détection de gesture.
+ //gestureLocked = false;
+ //On débloque la notification de nouveau mode.
+ modLocked = false;
+ lastCode = "";
+ //On arrête le timer.
+ _userPositionTimer.Stop();
}
/*
@@ -181,22 +200,32 @@
public void GesturePerformed(String code)
{
//Si le code vient d'être envoyé, on passe.
- if (lastCode.Equals(code))
+ /*if (lastCode.Equals(code))
return;
- lastCode = code;
+ lastCode = code;*/
//Si une gesture a été effectuée, on bloque un certain temps.
if (!gestureLocked)
{
gestureLocked = true;
//On crée un message contenant le code à envoyer.
- if (!messageCreated)
- {
- messageCreated = true;
- gestureMessage = "2-" + code;
+ //if (!gesturesMessageCreated)
+ //{
+ gesturesMessageCreated = true;
+ gesturesMessage = "2-" + code;
+
+ //Console.WriteLine(gesturesMessage);
+
+ foreach (var socket in allSockets.ToList())
+ {
+ socket.Send(gesturesMessage);
+ }
+
//On démarre le timer.
- _timer.Start();
- }
+ _gesturesTimer.Start();
+
+ //Console.WriteLine(gestureMessage);
+ //}
}
}
@@ -206,22 +235,29 @@
public void ModeNotification(String code)
{
//Si le code vient d'être envoyé, on passe.
- if (lastCode.Equals(code))
+ /*if (lastCode.Equals(code))
return;
- lastCode = code;
+ lastCode = code;*/
//Si on a été notifié.
if (!modLocked)
{
modLocked = true;
//On crée un message contenant le code à envoyer.
- if (!messageCreated)
- {
- messageCreated = true;
- gestureMessage = "2-" + code;
+ //if (!modeMessageCreated)
+ //{
+ modeMessageCreated = true;
+ modeMessage = "2-" + code;
//On démarre le timer.
- _timer.Start();
- }
+
+ foreach (var socket in allSockets.ToList())
+ {
+ socket.Send(modeMessage);
+ }
+ _userPositionTimer.Start();
+
+ //Console.WriteLine(modeMessage);
+ //}
}
}
@@ -234,16 +270,28 @@
{
while (true)
{
- //S'il existe un message.
- if (gestureMessage != null && !gestureMessage.Equals("") && !gestureMessage.Equals(prevGestureMessage))
+ /*//S'il existe un message de gesture.
+ if (gesturesMessage != null && !gesturesMessage.Equals(""))// && !gesturesMessage.Equals(prevGestureMessage))
{
//On l'envoie au client (au host et au port spécifiés dans le constructeur).
foreach (var socket in allSockets.ToList())
{
- socket.Send(gestureMessage);
- prevGestureMessage = gestureMessage;
+ socket.Send(gesturesMessage);
+ //prevGestureMessage = gesturesMessage;
}
}
+
+ //S'il existe un message de mode.
+ if (modeMessage != null && !modeMessage.Equals(""))// && !modeMessage.Equals(prevModeMessage))
+ {
+ //On l'envoie au client (au host et au port spécifiés dans le constructeur).
+ foreach (var socket in allSockets.ToList())
+ {
+ socket.Send(modeMessage);
+ //prevModeMessage = modeMessage;
+ }
+ }*/
+
//Si la main gauche est détectée.
if (leftHandMessage != null && !leftHandMessage.Equals("") && !leftHandMessage.Equals(prevLeftHandMessage))
{
@@ -269,11 +317,19 @@
Thread.Sleep(25);
//Si une gesture a été effectuée et que le délai d'attente est expiré.
- if (messageCreated && !gestureLocked && !modLocked)
+ if (gesturesMessageCreated && !gestureLocked)
{
//On débloque la détection de gesture et on supprime l'objet envoyant les messages OSC de gesture.
- messageCreated = false;
- gestureMessage = "";
+ gesturesMessageCreated = false;
+ gesturesMessage = "";
+ }
+
+ //Si un mode a été effectuée et que le délai d'attente est expiré.
+ if (modeMessageCreated && !modLocked)
+ {
+ //On débloque la détection de gesture et on supprime l'objet envoyant les messages OSC de gesture.
+ modeMessageCreated = false;
+ modeMessage = "";
}
}
}
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/Debug/App.config
--- a/middleware/Debug/App.config Wed May 30 10:22:46 2012 +0200
+++ b/middleware/Debug/App.config Thu Jun 21 16:52:56 2012 +0200
@@ -26,7 +26,7 @@
- 1
+ 0.5
@@ -37,43 +37,43 @@
-
- 1.5
-
- 1
-
-
- 3.2
-
-
- 1.8
+ 0.5
127.0.0.1
-
- 8080
-
1000
-
- 25
-
10
10
+
+ 8080
+
+
+ 20
+
+
+ 1
+
+
+ 2.3
+
+
+ 1.4
+
- 0.01
+ 0.1
- 1.5
+ 1,5
1
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/Debug/DebugParameters.xaml.cs
--- a/middleware/Debug/DebugParameters.xaml.cs Wed May 30 10:22:46 2012 +0200
+++ b/middleware/Debug/DebugParameters.xaml.cs Thu Jun 21 16:52:56 2012 +0200
@@ -43,7 +43,7 @@
rm = new ResourceManager("Trakers.Debug.Properties.Resources", Assembly.GetExecutingAssembly());
debug = _debug;
InitializeComponent();
- getParameters();
+ getParameters();
}
/*
@@ -51,6 +51,7 @@
*/
public void getParameters()
{
+
searchMinDistanceTB.Text = debug.getMinDistHands().ToString();
searchMaxDistanceTB.Text = debug.getMaxDistHands().ToString();
minDistanceTB.Text = debug.getMinDist().ToString();
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/Debug/DebugWindow.xaml
--- a/middleware/Debug/DebugWindow.xaml Wed May 30 10:22:46 2012 +0200
+++ b/middleware/Debug/DebugWindow.xaml Thu Jun 21 16:52:56 2012 +0200
@@ -47,12 +47,12 @@
-
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/Debug/DebugWindow.xaml.cs
--- a/middleware/Debug/DebugWindow.xaml.cs Wed May 30 10:22:46 2012 +0200
+++ b/middleware/Debug/DebugWindow.xaml.cs Thu Jun 21 16:52:56 2012 +0200
@@ -31,6 +31,7 @@
using System.Reflection;
using System.Timers;
using System.Configuration;
+using System.IO;
namespace Trakers.Debug
{
@@ -101,10 +102,22 @@
connexionHost = "127.0.0.1";
connexionPort = 80;
timerElapsing = 1000;
+ imagesToShow = 20;
+ takenPoints = 10;
+ directionChangeTresholdXY = 10;
+ directionChangeTresholdZ = 0.01f;
+ /*minDistHands = 1.0f;
+ maxDistHands = 5.5f;
+ minDist = 1.0f;
+ maxDist = 6.0f;
+ zeroPoint = 1.7f;
+ connexionHost = "127.0.0.1";
+ connexionPort = 80;
+ timerElapsing = 1000;
imagesToShow = 25;
takenPoints = 10;
directionChangeTresholdXY = 10;
- directionChangeTresholdZ = 0.01f;
+ directionChangeTresholdZ = 0.01f;*/
}
//On charge la fenêtre de paramètres.
@@ -255,6 +268,64 @@
}
}
+ /*public void showCorrect(bool C1, bool C2, bool C3, bool C4, bool C5, bool C6, bool C7, bool C8, bool C9, bool C10, bool C11)
+ {
+ if(C1)
+ R0.Fill = System.Windows.Media.Brushes.Blue;
+ else
+ R0.Fill = System.Windows.Media.Brushes.DarkGray;
+
+ if (C2)
+ R1.Fill = System.Windows.Media.Brushes.Blue;
+ else
+ R1.Fill = System.Windows.Media.Brushes.DarkGray;
+
+ if (C3)
+ R2.Fill = System.Windows.Media.Brushes.Blue;
+ else
+ R2.Fill = System.Windows.Media.Brushes.DarkGray;
+
+ if (C4)
+ R3.Fill = System.Windows.Media.Brushes.Blue;
+ else
+ R3.Fill = System.Windows.Media.Brushes.DarkGray;
+
+ if (C5)
+ R4.Fill = System.Windows.Media.Brushes.Blue;
+ else
+ R4.Fill = System.Windows.Media.Brushes.DarkGray;
+
+ if (C6)
+ R5.Fill = System.Windows.Media.Brushes.Blue;
+ else
+ R5.Fill = System.Windows.Media.Brushes.DarkGray;
+
+ if (C7)
+ R6.Fill = System.Windows.Media.Brushes.Blue;
+ else
+ R6.Fill = System.Windows.Media.Brushes.DarkGray;
+
+ if (C8)
+ R7.Fill = System.Windows.Media.Brushes.Blue;
+ else
+ R7.Fill = System.Windows.Media.Brushes.DarkGray;
+
+ if (C9)
+ R8.Fill = System.Windows.Media.Brushes.Blue;
+ else
+ R8.Fill = System.Windows.Media.Brushes.DarkGray;
+
+ if (C10)
+ R9.Fill = System.Windows.Media.Brushes.Blue;
+ else
+ R9.Fill = System.Windows.Media.Brushes.DarkGray;
+
+ if (C11)
+ R10.Fill = System.Windows.Media.Brushes.Blue;
+ else
+ R10.Fill = System.Windows.Media.Brushes.DarkGray;
+ }*/
+
/*
* Affiche la distance de l'utilisateur dans le rendu visuel.
* Sous forme de nombre en m et de rectangles changeant de couleur en fonction de la distance.
@@ -641,6 +712,7 @@
Bitmap bitmap = null;
//S'il s'agit de telle ou telle gesture, on prend l'image correspondante dans les ressources,
//on la convertit et on l'affiche.
+
switch (gesture)
{
case "SWIPE-LEFT": bitmap = getImage(imgLocation + "\\swipe_left.png");
@@ -659,13 +731,15 @@
break;
case "PULL-BOTH": bitmap = getImage(imgLocation + "\\pull_both.png");
break;
- case "WAVE": bitmap = getImage(imgLocation + "\\wave.png");
+ case "WAVE": bitmap = getImage(imgLocation + "\\hello.png");
break;
case "BEND": bitmap = getImage(imgLocation + "\\bend.png");
break;
- case "CROSS": bitmap = getImage(imgLocation + "\\cross.png");
+ case "KNEE-UP": bitmap = getImage(imgLocation + "\\knee_up.png");
break;
- case "KNEE-UP": bitmap = getImage(imgLocation + "\\knee_up.png");
+ case "JUMP": bitmap = getImage(imgLocation + "\\jump.png");
+ break;
+ case "FALL": bitmap = getImage(imgLocation + "\\fall.png");
break;
}
Gestures.Source = CreateBitmapSourceFromBitmap(bitmap);
@@ -701,7 +775,7 @@
/*
* Méthode de chargement des paramètres (position du champ de recherche...).
*/
- public bool loadParameters()
+ /*public bool loadParameters()
{
try
{
@@ -732,6 +806,74 @@
return false;
}
return true;
+ }*/
+
+ public bool loadParameters()
+ {
+ try
+ {
+ String[] lines = System.IO.File.ReadAllLines("config.txt");
+
+ minDistHands = float.Parse(lines[0].Split(':')[1]);
+ minDist = float.Parse(lines[1].Split(':')[1]);
+ connexionHost = lines[2].Split(':')[1];
+ timerElapsing = int.Parse(lines[3].Split(':')[1]);
+ takenPoints = int.Parse(lines[4].Split(':')[1]);
+ directionChangeTresholdXY = int.Parse(lines[5].Split(':')[1]);
+ connexionPort = int.Parse(lines[6].Split(':')[1]);
+ imagesToShow = int.Parse(lines[7].Split(':')[1]);
+ maxDistHands = float.Parse(lines[8].Split(':')[1]);
+ maxDist = float.Parse(lines[9].Split(':')[1]);
+ zeroPoint = float.Parse(lines[10].Split(':')[1]);
+ directionChangeTresholdZ = float.Parse(lines[11].Split(':')[1]);
+ }
+ catch (Exception e)
+ {
+ StreamWriter SW;
+ try
+ {
+ SW = File.CreateText("ErrorFile.txt");
+ SW.WriteLine(e.Message);
+ SW.Close();
+ }
+ catch { }
+
+ return false;
+ }
+
+ if (maxDistHands <= 0f || minDistHands <= 0f || maxDistHands > maxDist || minDistHands > maxDist ||
+ minDistHands >= maxDistHands || zeroPoint < maxDistHands || minDistHands > minDist ||
+ zeroPoint >= maxDist || connexionPort < 0 || timerElapsing < 0 || imagesToShow < 1 ||
+ takenPoints <= 0 || directionChangeTresholdXY < 0 || directionChangeTresholdZ < 0)
+ {
+ ExceptionLbl.Content = rm.GetString("loadParametersIncorrect");
+
+ StreamWriter SW;
+ try
+ {
+ SW = File.CreateText("ErrorFile.txt");
+ if (maxDistHands <= 0f) { SW.WriteLine("searchMaxDistance <= 0"); }
+ if (minDistHands <= 0f) { SW.WriteLine("minDistance <= 0"); }
+ if (maxDistHands > maxDist) { SW.WriteLine("searchMaxDistance > maxDistance"); }
+ if (minDistHands > maxDist) { SW.WriteLine("searchMinDistance > maxDistance"); }
+ if (minDistHands >= maxDistHands) { SW.WriteLine("searchMinDistance >= searchMaxDistance"); }
+ if (zeroPoint < maxDistHands) { SW.WriteLine("zeroPoint < searchMaxDistance"); }
+ if (minDistHands > minDist) { SW.WriteLine("searchMinDistance > minDistance"); }
+ if (zeroPoint >= maxDist) { SW.WriteLine("zeroPoint >= maxDistance"); }
+ if (connexionPort < 0) { SW.WriteLine("connexionPort < 0"); }
+ if (timerElapsing < 0) { SW.WriteLine("timerElapsing < 0"); }
+ if (imagesToShow < 1) { SW.WriteLine("imagesToShow < 1"); }
+ if (takenPoints <= 0) { SW.WriteLine("takenPoints <= 0"); }
+ if (directionChangeTresholdXY < 0) { SW.WriteLine("directionChangeTresholdXY < 0"); }
+ if (directionChangeTresholdZ < 0) { SW.WriteLine("directionChangeTresholdZ < 0"); }
+ SW.Close();
+ Console.WriteLine("Error File Created SucacessFully");
+ }
+ catch (Exception){}
+
+ return false;
+ }
+ return true;
}
/*
@@ -834,7 +976,7 @@
{
on = _on;
}
- public void setQuitMenu(MenuItem quitMenu)
+ /*public void setQuitMenu(MenuItem quitMenu)
{
QuitMenu = quitMenu;
}
@@ -845,7 +987,7 @@
public void setParamMenu(MenuItem parameters)
{
ParamMenu = parameters;
- }
+ }*/
public float getMinDistHands()
{
@@ -903,7 +1045,7 @@
{
return on;
}
- public MenuItem getQuitMenu()
+ /*public MenuItem getQuitMenu()
{
return QuitMenu;
}
@@ -914,7 +1056,7 @@
public MenuItem getParamMenu()
{
return ParamMenu;
- }
+ }*/
public void onR0(bool b)
{
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/Debug/Properties/Settings.Designer.cs
--- a/middleware/Debug/Properties/Settings.Designer.cs Wed May 30 10:22:46 2012 +0200
+++ b/middleware/Debug/Properties/Settings.Designer.cs Thu Jun 21 16:52:56 2012 +0200
@@ -1,7 +1,7 @@
-//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.261
+// Runtime Version:4.0.30319.269
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -25,7 +25,7 @@
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("1")]
+ [global::System.Configuration.DefaultSettingValueAttribute("0.5")]
public float searchMinDistance {
get {
return ((float)(this["searchMinDistance"]));
@@ -34,19 +34,7 @@
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("1.5")]
- public float searchMaxDistance {
- get {
- return ((float)(this["searchMaxDistance"]));
- }
- set {
- this["searchMaxDistance"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("1")]
+ [global::System.Configuration.DefaultSettingValueAttribute("0.5")]
public float minDistance {
get {
return ((float)(this["minDistance"]));
@@ -58,30 +46,6 @@
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("3.2")]
- public float maxDistance {
- get {
- return ((float)(this["maxDistance"]));
- }
- set {
- this["maxDistance"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("1.8")]
- public float zeroPoint {
- get {
- return ((float)(this["zeroPoint"]));
- }
- set {
- this["zeroPoint"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("127.0.0.1")]
public string connexionHost {
get {
@@ -94,18 +58,6 @@
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("80")]
- public int connexionPort {
- get {
- return ((int)(this["connexionPort"]));
- }
- set {
- this["connexionPort"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("1000")]
public int timerElapsing {
get {
@@ -118,18 +70,6 @@
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("25")]
- public int imagesToShow {
- get {
- return ((int)(this["imagesToShow"]));
- }
- set {
- this["imagesToShow"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("10")]
public int takenPoints {
get {
@@ -154,7 +94,67 @@
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("0.01")]
+ [global::System.Configuration.DefaultSettingValueAttribute("8080")]
+ public int connexionPort {
+ get {
+ return ((int)(this["connexionPort"]));
+ }
+ set {
+ this["connexionPort"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("20")]
+ public int imagesToShow {
+ get {
+ return ((int)(this["imagesToShow"]));
+ }
+ set {
+ this["imagesToShow"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("1")]
+ public float searchMaxDistance {
+ get {
+ return ((float)(this["searchMaxDistance"]));
+ }
+ set {
+ this["searchMaxDistance"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("2.3")]
+ public float maxDistance {
+ get {
+ return ((float)(this["maxDistance"]));
+ }
+ set {
+ this["maxDistance"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("1.4")]
+ public float zeroPoint {
+ get {
+ return ((float)(this["zeroPoint"]));
+ }
+ set {
+ this["zeroPoint"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0.1")]
public float directionChangeTresholdZ {
get {
return ((float)(this["directionChangeTresholdZ"]));
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/Debug/Properties/Settings.settings
--- a/middleware/Debug/Properties/Settings.settings Wed May 30 10:22:46 2012 +0200
+++ b/middleware/Debug/Properties/Settings.settings Thu Jun 21 16:52:56 2012 +0200
@@ -3,40 +3,40 @@
- 1
-
-
- 1.5
+ 0.5
- 1
-
-
- 3.2
-
-
- 1.8
+ 0.5
127.0.0.1
-
- 80
-
1000
-
- 25
-
10
10
+
+ 8080
+
+
+ 20
+
+
+ 1
+
+
+ 2.3
+
+
+ 1.4
+
- 0.01
+ 0.1
\ No newline at end of file
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/Tracking/Gestures/JumpDetector.cs
--- a/middleware/Tracking/Gestures/JumpDetector.cs Wed May 30 10:22:46 2012 +0200
+++ b/middleware/Tracking/Gestures/JumpDetector.cs Thu Jun 21 16:52:56 2012 +0200
@@ -36,7 +36,7 @@
public JumpDetector(DebugWindow _debug) : base(_debug)
{
- gesturePeriod = (float)1;
+ gesturePeriod = (float)1.5;
indexesPerSecond = 30;
indexesToCheck = (int)(gesturePeriod * indexesPerSecond);
}
@@ -70,31 +70,75 @@
* HeadFarAboveBaseLine
*/
- //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][(int)JointType.Spine].Position.Y - localHistory[0][(int)JointType.ShoulderCenter].Position.Y);
+ //La distance de référence est ici la distance entre les épaules et les hanches.
+ refDistance = Math.Abs(localHistory[0][(int)JointType.ShoulderCenter].Position.Y - localHistory[0][(int)JointType.HipCenter].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
+ int middleIdx = 0;
+ int endIdx = 0;
bool topOfJump = false;
-
-
+ bool probableJump = false;
//De la position p1 à pn, on suit l'algorithme.
for (int i = beginIdx ; i < localHistory.Count ; i++)
{
-
- 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)
+ if (localHistory[i][(int)JointType.Spine].Position.Y + refDistance / 2 < localHistory[beginIdx][(int)JointType.Spine].Position.Y)
{
topOfJump = true;
- //Console.Out.WriteLine("TOP");
+ middleIdx = i;
+ debug.onR0(true);
}
- if (localHistory[i - 1][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HandRight].Position.Y && !topOfJump)
- return false;
+ if (localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[beginIdx][(int)JointType.Spine].Position.Y)
+ {
+ debug.onR0(false);
+ debug.onR1(false);
+ debug.onR2(false);
+ }
+ }
+
+ if (topOfJump)
+ {
+ for (int i = middleIdx; i < localHistory.Count; i++)
+ {
+ if (Math.Abs(localHistory[beginIdx][(int)JointType.Spine].Position.Y - localHistory[i][(int)JointType.Spine].Position.Y) < refDistance / 5 ||
+ localHistory[beginIdx][(int)JointType.Spine].Position.Y < localHistory[i][(int)JointType.Spine].Position.Y)
+ {
+ probableJump = true;
+ endIdx = i;
+ debug.onR1(true);
+ //Console.Out.WriteLine("TOP");
+ }
+ }
+ }
+ else
+ {
+ debug.onR0(false);
+ debug.onR1(false);
+ debug.onR2(false);
+ return false;
+ }
+
+ if (probableJump)
+ {
+ if (Math.Abs(localHistory[beginIdx][(int)JointType.Spine].Position.Z - localHistory[endIdx][(int)JointType.Spine].Position.Z) < 0.10)
+ {
+ debug.onR2(true);
+ return true;
+ }
+ }
+ else
+ {
+ debug.onR0(false);
+ debug.onR1(false);
+ debug.onR2(false);
+ return false;
+ }
+
+ //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
//OU si la position Y de la main est plus basse que la hanche
@@ -102,11 +146,11 @@
//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][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HandRight].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;
- }
+ return false;*/
+ //}
//Console.Out.WriteLine("OK");
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/Tracking/Gestures/SwipeDetector.cs
--- a/middleware/Tracking/Gestures/SwipeDetector.cs Wed May 30 10:22:46 2012 +0200
+++ b/middleware/Tracking/Gestures/SwipeDetector.cs Thu Jun 21 16:52:56 2012 +0200
@@ -65,12 +65,14 @@
for (int i = localHistory.Count - indexesToCheck + 1; i < localHistory.Count; i++)
{
//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 position Y de la main est plus basse que la hanche (les genoux)
//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][(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.Y > localHistory[i][(int)JointType.HipCenter].Position.Y ||
+ localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.KneeLeft].Position.Y ||
+ localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.KneeRight].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;
@@ -120,12 +122,14 @@
for (int i = localHistory.Count - indexesToCheck + 1; i < localHistory.Count; i++)
{
//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 position Y de la main est plus basse que la hanche (les genoux)
//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][(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.Y > localHistory[i][(int)JointType.HipCenter].Position.Y ||
+ localHistory[i][(int)JointType.HandLeft].Position.Y > localHistory[i][(int)JointType.KneeLeft].Position.Y ||
+ localHistory[i][(int)JointType.HandLeft].Position.Y > localHistory[i][(int)JointType.KneeRight].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;
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/Tracking/Gestures/UserPositionDetector.cs
--- a/middleware/Tracking/Gestures/UserPositionDetector.cs Wed May 30 10:22:46 2012 +0200
+++ b/middleware/Tracking/Gestures/UserPositionDetector.cs Thu Jun 21 16:52:56 2012 +0200
@@ -89,15 +89,16 @@
public int ImagesToShow(float proximity, int N)
{
//Si la proximité est nulle, on retourne 0.
- if (proximity == 0f)
+ if (proximity <= 20f)
return 0;
//Si on n'est pas encore trop près mais qu'on dépasse le point zéro.
- if (proximity >= 90f)
+ if (proximity >= 80f)
return N;
//Pour chaque intervalle de déciles (dans les pourcentages), le nombre de dizaines
//du pourcentage de proximité plus un, fois le nombre de dizaines d'images seront affichées.
- return (((int)proximity / 10) + 1) * ((int)N / 2);
+ //return (((int)proximity / 10) + 1) * ((int)N / 2);
+ return ((int)proximity / 10) * ((int)N / 10);
}
}
}
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/Tracking/Gestures/WaveDetector.cs
--- a/middleware/Tracking/Gestures/WaveDetector.cs Wed May 30 10:22:46 2012 +0200
+++ b/middleware/Tracking/Gestures/WaveDetector.cs Thu Jun 21 16:52:56 2012 +0200
@@ -61,25 +61,32 @@
//De la position p1 à pn, on suit l'algorithme.
for (int i = localHistory.Count - indexesToCheck + 1; i < localHistory.Count; i++)
{
- /*if (localHistory[i][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.ElbowRight].Position.Y + refDistance)
- debug.onR0(true);
+ /*if (localHistory[i][(int)JointType.HandRight].Position.Y + refDistance / 2 > localHistory[i][(int)JointType.ElbowRight].Position.Y)
+ debug.onR0(false);
else
- debug.onR0(false);
- if (localHistory[i][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.HipCenter].Position.Y)
+ debug.onR0(true);
+ if (localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HipCenter].Position.Y)
+ debug.onR1(false);
+ else
debug.onR1(true);
+ if (localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.WristRight].Position.Y)
+ debug.onR2(false);
else
- debug.onR1(false);
- if (localHistory[i][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.WristRight].Position.Y + refDistance / 4)
debug.onR2(true);
+ if (Math.Abs(localHistory[i][(int)JointType.HandRight].Position.Z - localHistory[i][(int)JointType.Head].Position.Z) > 0.20)
+ debug.onR3(false);
else
- debug.onR2(false);*/
+ debug.onR3(true);*/
//Si la position Y de la main droite est plus haute que le coude + la distance de référence
//OU si la position Y de la main droite est plus basse que la hanche
- //OU si la position Y de la main droite est plus haute que le poignet + le quart de la distance de référence.
+ //OU si la position Y de la main droite est plus haute que le poignet + le quart de la distance de référence
+ //OU si la distance Y de la main à la tete est plus grande que la distance de référence
+ //OU si la distance Z de la main à la tete est plus grande que 20 cm.
//Alors la main en question ne fait pas de Wave.
- if (localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.ElbowRight].Position.Y + refDistance ||
+ if (localHistory[i][(int)JointType.HandRight].Position.Y + refDistance / 2 > localHistory[i][(int)JointType.ElbowRight].Position.Y ||
localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HipCenter].Position.Y ||
- localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.WristRight].Position.Y + refDistance / 4)
+ localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.WristRight].Position.Y ||
+ Math.Abs(localHistory[i][(int)JointType.HandRight].Position.Z - localHistory[i][(int)JointType.Head].Position.Z) > 0.20)
return false;
//On vérifie si la main à bougé vers la droite.
@@ -88,7 +95,7 @@
movedRight = true;
//Si la main a bougé vers la droite, on regarde si elle est retournée à sa position initiale.
- if (movedRight && localHistory[i][(int)JointType.HandRight].Position.X <= startPosX)
+ if (movedRight && Math.Abs(localHistory[i][(int)JointType.HandRight].Position.X - startPosX) <= refDistance)
{
history.Clear();
return true;
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/Tracking/Postures/CorrectPosture.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/middleware/Tracking/Postures/CorrectPosture.cs Thu Jun 21 16:52:56 2012 +0200
@@ -0,0 +1,77 @@
+/*
+* This file is part of the TraKERS\Middleware package.
+*
+* (c) IRI
+*
+* For the full copyright and license information, please view the LICENSE
+* file that was distributed with this source code.
+*/
+
+/*
+ * Projet : TraKERS
+ * Module : MIDDLEWARE
+ * Sous-Module : Tracking/Postures
+ * Classe : BendDetector
+ *
+ * Auteur : alexandre.bastien@iri.centrepompidou.fr
+ *
+ * Fonctionnalités : Permet de détecter si l'utilisateur est bien tracké.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Kinect;
+using Trakers.Debug;
+
+namespace Trakers.Tracking.Postures
+{
+ public class CorrectPosture : PostureDetector
+ {
+ public CorrectPosture(DebugWindow _debug)
+ : base(_debug)
+ {
+ }
+
+ /*
+ * Méthode de détection du penché.
+ */
+ public bool CheckForCorrectPosture()
+ {
+ //Crée un état local afin de pouvoir analyser s'il y a une posture.
+ List localState = new List(currentState);
+
+ bool c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13;
+
+ //Si les genoux sont plus hauts que le centre
+ //OU si les pieds sont plus hauts que le centre
+ //OU si la tête est plus basse que les hanches
+ //OU si les épaules sont plus basses que les genoux
+ //OU si les épaules droites et gauches sont trop proches
+ //OU si les genoux droites et gauches sont trop proches
+ //OU si les pieds sont plus hauts que les genoux, les genoux étant plus bas que le bassin
+ //OU si les genoux sont inversés par rapport aux épaules
+ //Alors on ne s'est pas tracké.
+ c1 = localState[(int)JointType.KneeLeft].Position.Y < localState[(int)JointType.Spine].Position.Y;
+ c2 = localState[(int)JointType.KneeRight].Position.Y < localState[(int)JointType.Spine].Position.Y;
+ c3 = localState[(int)JointType.FootLeft].Position.Y < localState[(int)JointType.Spine].Position.Y;
+ c4 = localState[(int)JointType.FootRight].Position.Y < localState[(int)JointType.Spine].Position.Y;
+ c5 = localState[(int)JointType.Head].Position.Y > localState[(int)JointType.HipCenter].Position.Y;
+ c6 = localState[(int)JointType.ShoulderCenter].Position.Y > localState[(int)JointType.KneeLeft].Position.Y;
+ c7 = localState[(int)JointType.ShoulderCenter].Position.Y > localState[(int)JointType.KneeRight].Position.Y;
+ c8 = Math.Abs(localState[(int)JointType.ShoulderLeft].Position.X - localState[(int)JointType.ShoulderRight].Position.X) < 0.20;
+ c9 = Math.Abs(localState[(int)JointType.KneeLeft].Position.X - localState[(int)JointType.KneeRight].Position.X) < 0.20;
+ c10 = localState[(int)JointType.FootLeft].Position.Y < localState[(int)JointType.KneeLeft].Position.Y && localState[(int)JointType.KneeLeft].Position.Y > localState[(int)JointType.HipCenter].Position.Y;
+ c11 = localState[(int)JointType.FootRight].Position.Y < localState[(int)JointType.KneeRight].Position.Y && localState[(int)JointType.KneeRight].Position.Y > localState[(int)JointType.HipCenter].Position.Y;
+ c12 = localState[(int)JointType.ShoulderRight].Position.X < localState[(int)JointType.ShoulderLeft].Position.X && localState[(int)JointType.KneeRight].Position.X > localState[(int)JointType.KneeLeft].Position.X;
+ c13 = localState[(int)JointType.ShoulderRight].Position.X > localState[(int)JointType.ShoulderLeft].Position.X && localState[(int)JointType.KneeRight].Position.X < localState[(int)JointType.KneeLeft].Position.X;
+ if (c1 || c2 || c3 || c4 || c5 || c6 || c7 || c8 || c9 || c10 || c11 || c12 || c13)
+ {
+ //debug.showCorrect(c1, c2, c3, c4, c5, c6, c7, c8, c9, c12, c13);
+ //Console.WriteLine("NOT DETECTED");
+ return false;
+ }
+ return true;
+ }
+ }
+}
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/Tracking/Postures/FallDetector.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/middleware/Tracking/Postures/FallDetector.cs Thu Jun 21 16:52:56 2012 +0200
@@ -0,0 +1,74 @@
+/*
+* This file is part of the TraKERS\Middleware package.
+*
+* (c) IRI
+*
+* For the full copyright and license information, please view the LICENSE
+* file that was distributed with this source code.
+*/
+
+/*
+ * Projet : TraKERS
+ * Module : MIDDLEWARE
+ * Sous-Module : Tracking/Gestures
+ * Classe : JumpDetector
+ *
+ * Auteur : alexandre.bastien@iri.centrepompidou.fr
+ *
+ * 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;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Kinect;
+using Trakers.Debug;
+
+namespace Trakers.Tracking.Postures
+{
+ public class FallDetector : PostureDetector
+ {
+ static int n = 0;
+
+ public FallDetector(DebugWindow _debug)
+ : base(_debug)
+ {
+ }
+
+ /*
+ * Méthode de détection du fall.
+ */
+ public bool CheckForFall()
+ {
+ //Crée un état local afin de pouvoir analyser s'il y a une posture.
+ List localState = new List(currentState);
+
+ /*if (localState[(int)JointType.KneeLeft].Position.Z + 0.10 < localState[(int)JointType.HipCenter].Position.Z)
+ debug.onR0(true);
+ else
+ debug.onR0(false);
+ if(localState[(int)JointType.KneeRight].Position.Z + 0.10 < localState[(int)JointType.HipCenter].Position.Z)
+ debug.onR1(true);
+ else
+ debug.onR1(false);
+ if (Math.Abs(localState[(int)JointType.HipCenter].Position.Z - localState[(int)JointType.Head].Position.Z) <= 0.20)
+ debug.onR2(true);
+ else
+ debug.onR2(false);*/
+
+ //Si les genoux ne sont pas éloignés d'au moins 20cm vers l'avant par rapport aux hanches
+ //OU si les hanches et la tête ne sont pas au même niveau avec 20 cm d'erreur.
+ //Alors on ne fait pas un fall.
+ if (localState[(int)JointType.KneeLeft].Position.Z + 0.15 >= localState[(int)JointType.HipCenter].Position.Z ||
+ localState[(int)JointType.KneeRight].Position.Z + 0.15 >= localState[(int)JointType.HipCenter].Position.Z ||
+ //||
+ Math.Abs(localState[(int)JointType.HipCenter].Position.Z - localState[(int)JointType.Head].Position.Z) > 0.20)
+ return false;
+ return true;
+ }
+ }
+}
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/Tracking/Tracking.csproj
--- a/middleware/Tracking/Tracking.csproj Wed May 30 10:22:46 2012 +0200
+++ b/middleware/Tracking/Tracking.csproj Thu Jun 21 16:52:56 2012 +0200
@@ -49,6 +49,7 @@
+
@@ -57,6 +58,7 @@
+
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/push_right.jpg
Binary file middleware/push_right.jpg has changed
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/MainModule.csproj
--- a/middleware/src/MainModule.csproj Wed May 30 10:22:46 2012 +0200
+++ b/middleware/src/MainModule.csproj Thu Jun 21 16:52:56 2012 +0200
@@ -83,6 +83,8 @@
+
+
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/MainModule/Events/FallEventArgs.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/middleware/src/MainModule/Events/FallEventArgs.cs Thu Jun 21 16:52:56 2012 +0200
@@ -0,0 +1,42 @@
+/*
+* This file is part of the TraKERS\Middleware package.
+*
+* (c) IRI
+*
+* For the full copyright and license information, please view the LICENSE
+* file that was distributed with this source code.
+*/
+
+/*
+ * Projet : TraKERS
+ * Module : MIDDLEWARE
+ * Sous-Module : MainModule/Events
+ * Classe : FallEventArgs
+ *
+ * Auteur : alexandre.bastien@iri.centrepompidou.fr
+ *
+ * Fonctionnalités : Cette classe contient les membres utilisés lors de l'appel au listener correspondant
+ * à l'événement : L'utilisateur a sauté.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Trakers.Debug;
+using Trakers.Communication;
+
+namespace Trakers.MainModule.Events
+{
+ public class FallEventArgs : MainEventArgs
+ {
+
+ /*
+ * Constructeur.
+ */
+ public FallEventArgs(Server _server, DebugWindow _debug)
+ : base(_server, _debug)
+ {
+ }
+ }
+}
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/MainModule/Events/FallListener.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/middleware/src/MainModule/Events/FallListener.cs Thu Jun 21 16:52:56 2012 +0200
@@ -0,0 +1,40 @@
+/*
+* This file is part of the TraKERS\Middleware package.
+*
+* (c) IRI
+*
+* For the full copyright and license information, please view the LICENSE
+* file that was distributed with this source code.
+*/
+
+/*
+ * Projet : TraKERS
+ * Module : MIDDLEWARE
+ * Sous-Module : MainModule/Events
+ * Classe : JumpListener
+ *
+ * Auteur : alexandre.bastien@iri.centrepompidou.fr
+ *
+ * Fonctionnalités : Ce listener écoute l'événement du type : L'utilisateur a sauté.
+ * Il contient le code a être éxecuté au cas où cet événement survient.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Trakers.MainModule.Events
+{
+ public class FallListener
+ {
+ /*
+ * Méthode appelée lorsque on a l'événement : L'utilisateur a sauté.
+ */
+ public void showAndSend(object o, FallEventArgs e)
+ {
+ e.debug.showGesture("FALL");
+ e.server.GesturePerformed("FALL");
+ }
+ }
+}
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/MainModule/Events/ModChangeListener.cs
--- a/middleware/src/MainModule/Events/ModChangeListener.cs Wed May 30 10:22:46 2012 +0200
+++ b/middleware/src/MainModule/Events/ModChangeListener.cs Thu Jun 21 16:52:56 2012 +0200
@@ -36,7 +36,7 @@
public void showAndSend(object o, ModChangeEventArgs e)
{
//e.debug.showGesture(e.code);
- //e.server.ModeNotification(e.code);
+ e.server.ModeNotification(e.code);
}
}
}
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/MainModule/Events/UserPositionListener.cs
--- a/middleware/src/MainModule/Events/UserPositionListener.cs Wed May 30 10:22:46 2012 +0200
+++ b/middleware/src/MainModule/Events/UserPositionListener.cs Thu Jun 21 16:52:56 2012 +0200
@@ -35,7 +35,8 @@
public void showAndSend(object o, UserPositionEventArgs e)
{
e.debug.showDistance(e.distance);
- e.server.GesturePerformed("MOSSHOW-" + e.imagesToShow);
+ e.server.ModeNotification("INCOMING-" + e.imagesToShow);
+ //Console.WriteLine("dist : " + e.distance + ", its : " + e.imagesToShow);
}
}
}
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/MainModule/Events/WaveListener.cs
--- a/middleware/src/MainModule/Events/WaveListener.cs Wed May 30 10:22:46 2012 +0200
+++ b/middleware/src/MainModule/Events/WaveListener.cs Thu Jun 21 16:52:56 2012 +0200
@@ -33,8 +33,8 @@
*/
public void showAndSend(object o, WaveEventArgs e)
{
- e.debug.showGesture("WAVE");
- e.server.GesturePerformed("WAVE");
+ e.debug.showGesture("HELLO");
+ e.server.GesturePerformed("HELLO");
}
}
}
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/MainModule/KinectMain.cs
--- a/middleware/src/MainModule/KinectMain.cs Wed May 30 10:22:46 2012 +0200
+++ b/middleware/src/MainModule/KinectMain.cs Thu Jun 21 16:52:56 2012 +0200
@@ -6,7 +6,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-
/*
* Projet : TraKERS
* Module : MIDDLEWARE
@@ -22,17 +21,14 @@
* son squelette, la détection de ses mains.
* Découpe l'interaction avec le middleware en différents modes.
*/
-
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Windows.Documents;
+using System.Windows;
using Microsoft.Kinect;
using Trakers.Communication;
+using Trakers.Debug;
using Trakers.MainModule.Events;
-using Trakers.Tracking.Search;
-using Trakers.Debug;
-using System.Windows;
using Trakers.Tracking.Gestures;
using Trakers.Tracking.Postures;
@@ -57,6 +53,8 @@
public delegate void PushHandler(object o, PushEventArgs e);
//Il s'agit de la fonction permettant d'appeler les fonctions des événements Jump.
public delegate void JumpHandler(object o, JumpEventArgs e);
+ //Il s'agit de la fonction permettant d'appeler les fonctions des événements Fall.
+ public delegate void FallHandler(object o, FallEventArgs e);
//Il s'agit de la fonction permettant d'appeler les fonctions des événements Wave.
public delegate void WaveHandler(object o, WaveEventArgs e);
//Il s'agit de la fonction permettant d'appeler les fonctions des événements Circle.
@@ -79,6 +77,8 @@
private CrossDetector crossDetector;
//Détecteur de levé de genou.
private KneeUpDetector kneeUpDetector;
+ //Détecteur de position correcte.
+ private CorrectPosture correctPostureDetector;
//Détecteur de swipes.
private SwipeDetector swipeDetector;
@@ -86,6 +86,8 @@
private PushDetector pushDetector;
//Détecteur de jumps.
private JumpDetector jumpDetector;
+ //Détecteur de falls.
+ private FallDetector fallDetector;
//Détecteur de waves.
private WaveDetector waveDetector;
//Détecteur de cercles.
@@ -118,6 +120,8 @@
public static event PushHandler PushEvent;
//L'événement jump.
public static event JumpHandler JumpEvent;
+ //L'événement fall.
+ public static event FallHandler FallEvent;
//L'événement wave.
public static event WaveHandler WaveEvent;
//L'événement circle.
@@ -139,11 +143,13 @@
bendDetector = new BendDetector(debug);
crossDetector = new CrossDetector(debug);
kneeUpDetector = new KneeUpDetector(debug);
+ correctPostureDetector = new CorrectPosture(debug);
//On crée les détecteurs de gestes.
swipeDetector = new SwipeDetector(debug);
pushDetector = new PushDetector(debug);
jumpDetector = new JumpDetector(debug);
+ fallDetector = new FallDetector(debug);
waveDetector = new WaveDetector(debug);
circleDetector = new CircleDetector(debug);
//On crée le détecteur de proximité.
@@ -166,8 +172,23 @@
debug.getSwitch().Click += new RoutedEventHandler(Switch_ClickInKinectMain);
debug.Loaded += new RoutedEventHandler(Window_LoadedInKinectMain);
debug.Closed += new EventHandler(Window_CloseInKinectMain);
- debug.getQuitMenu().Click += new RoutedEventHandler(Quit_ClickInKinectMain);
- debug.getParametersWindow().getModButton().Click += new RoutedEventHandler(updateParameters);
+ /*debug.getQuitMenu().Click += new RoutedEventHandler(Quit_ClickInKinectMain);
+ debug.getParametersWindow().getModButton().Click += new RoutedEventHandler(updateParameters);*/
+
+ /*Console.WriteLine("DEBUG");
+
+ Console.WriteLine("searchMinDistance:" + debug.getMinDistHands());
+ Console.WriteLine("minDistance:" + debug.getMinDist());
+ Console.WriteLine("connexionHost:" + debug.getConnexionHost());
+ Console.WriteLine("timerElapsing:" + debug.getTimerElapsing());
+ Console.WriteLine("takenPoints:" + debug.getTakenPoints());
+ Console.WriteLine("directionChangeTresholdXY:" + debug.getDirectionChangeTresholdXY());
+ Console.WriteLine("connexionPort:" + debug.getConnexionPort());
+ Console.WriteLine("imagesToShow:" + debug.getImagesToShow());
+ Console.WriteLine("searchMaxDistance:" + debug.getMaxDistHands());
+ Console.WriteLine("maxDistance:" + debug.getMaxDist());
+ Console.WriteLine("zeroPoint:" + debug.getZeroPoint());
+ Console.WriteLine("directionChangeTresholdZ:" + debug.getDirectionChangeTresholdZ());*/
//On affiche la fenêtre de debug.
try
@@ -178,6 +199,47 @@
}
}
+ /*public bool loadParameters()
+ {
+ try
+ {
+ string[] lines = System.IO.File.ReadAllLines(@"config.txt");
+
+ foreach (string line in lines)
+ {
+ Console.WriteLine(line);
+ }
+
+ /*minDistHands = Properties.Settings.Default.searchMinDistance;
+ maxDistHands = Properties.Settings.Default.searchMaxDistance;
+ minDist = Properties.Settings.Default.minDistance;
+ maxDist = Properties.Settings.Default.maxDistance;
+ zeroPoint = Properties.Settings.Default.zeroPoint;
+ connexionHost = Properties.Settings.Default.connexionHost;
+ connexionPort = Properties.Settings.Default.connexionPort;
+ timerElapsing = Properties.Settings.Default.timerElapsing;
+ imagesToShow = Properties.Settings.Default.imagesToShow;
+ takenPoints = Properties.Settings.Default.takenPoints;
+ directionChangeTresholdXY = Properties.Settings.Default.directionChangeTresholdXY;
+ directionChangeTresholdZ = Properties.Settings.Default.directionChangeTresholdZ;*/
+ /*}
+ catch (Exception)
+ {
+ return false;
+ }
+
+ if (maxDistHands <= 0f || minDistHands <= 0f || maxDistHands > maxDist || minDistHands > maxDist ||
+ minDistHands >= maxDistHands || zeroPoint < maxDistHands || minDistHands > minDist ||
+ zeroPoint >= maxDist || connexionPort < 0 || timerElapsing < 0 || imagesToShow < 1 ||
+ takenPoints <= 0 || directionChangeTresholdXY < 0 || directionChangeTresholdZ < 0)
+ {
+ ExceptionLbl.Content = rm.GetString("loadParametersIncorrect");
+ Console.WriteLine(ExceptionLbl.Content);
+ return false;
+ }
+ return true;
+ }
+
/*
* Envoi les paramètres mis à jour dans les différents modules.
*/
@@ -264,6 +326,10 @@
JumpListener jumpListener = new JumpListener();
JumpEvent += new JumpHandler(jumpListener.showAndSend);
+ //Fonction appelée lorsque l'utilisateur effectue un Fall.
+ FallListener fallListener = new FallListener();
+ FallEvent += new FallHandler(fallListener.showAndSend);
+
//Fonction appelée lorsque l'utilisateur effectue un Wave.
WaveListener waveListener = new WaveListener();
WaveEvent += new WaveHandler(waveListener.showAndSend);
@@ -465,6 +531,19 @@
GestureDetector.UpdateSkeletonHistory(joints);
PostureDetector.UpdateSkeletonState(joints);
+ if (!correctPostureDetector.CheckForCorrectPosture())
+ {
+ debug.hideSkeleton();
+ modeManagement.DetectProximityBasedModes(0);
+ //Console.WriteLine("NO-USER");
+ LeftHandQuitEventArgs leftHandQuitEvent = new LeftHandQuitEventArgs(server, debug);
+ OnLeftHandQuitEvent(leftHandQuitEvent);
+ RightHandQuitEventArgs rightHandQuitEvent = new RightHandQuitEventArgs(server, debug);
+ OnRightHandQuitEvent(rightHandQuitEvent);
+
+ return;
+ }
+
//Si la main gauche est dans le champ, on lance l'événement approprié.
if (handLeft.Position.Z < debug.getMaxDistHands() && handLeft.Position.Z > debug.getMinDistHands())
{
@@ -522,6 +601,20 @@
OnKneeUpEvent(kneeUpEvent);
}
+ //Si l'utilisateur a fait un jump.
+ if (jumpDetector.CheckForJump())
+ {
+ JumpEventArgs jumpEvent = new JumpEventArgs(server, debug);
+ OnJumpEvent(jumpEvent);
+ }
+
+ //Si l'utilisateur a fait un fall.
+ if (fallDetector.CheckForFall())
+ {
+ FallEventArgs fallEvent = new FallEventArgs(server, debug);
+ OnFallEvent(fallEvent);
+ }
+
//Si l'utilisateur effectue un swipe left.
if (swipeDetector.CheckForSwipeLeft())
{
@@ -568,7 +661,7 @@
modeManagement.DetectProximityBasedModes(proximity);
- if (proximity > 0f)
+ if (proximity >= 10f)
{
UserPositionEventArgs userPositionEvent = new UserPositionEventArgs(server, debug, proximity, numberOfImages);
OnUserPositionEvent(userPositionEvent);
@@ -698,6 +791,15 @@
}
/*
+ * Initialise l'événement et fait appel aux fonctions du listener quand l'utilisateur effectue un fall.
+ */
+ public static void OnFallEvent(FallEventArgs e)
+ {
+ if (FallEvent != null)
+ FallEvent(new object(), e);
+ }
+
+ /*
* Initialise l'événement et fait appel aux fonctions du listener quand l'utilisateur effectue un cercle.
*/
public static void OnCircleEvent(CircleEventArgs e)
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/MainModule/ModeManagement.cs
--- a/middleware/src/MainModule/ModeManagement.cs Wed May 30 10:22:46 2012 +0200
+++ b/middleware/src/MainModule/ModeManagement.cs Thu Jun 21 16:52:56 2012 +0200
@@ -74,14 +74,14 @@
if (proximity < 10f && currentMode != Mode.NO_USER)
{
currentMode = Mode.NO_USER;
- ModChangeEventArgs modChangeEvent = new ModChangeEventArgs(server, debug, "NO_USER");
+ ModChangeEventArgs modChangeEvent = new ModChangeEventArgs(server, debug, "NO-USER");
OnModChangeEvent(modChangeEvent);
}
//S'il n'est pas encore au point d'interaction maximale, on considère qu'il est en chemin.
else if (proximity >= 10f && proximity < 100f && currentMode != Mode.USER_INCOMING)
{
currentMode = Mode.USER_INCOMING;
- ModChangeEventArgs modChangeEvent = new ModChangeEventArgs(server, debug, "USER_INCOMING");
+ ModChangeEventArgs modChangeEvent = new ModChangeEventArgs(server, debug, "USER-INCOMING");
OnModChangeEvent(modChangeEvent);
}
//S'il est arrivé au point, il a la mosaïque complète.
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/Resources/bend.png
Binary file middleware/src/Resources/bend.png has changed
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/Resources/fall.png
Binary file middleware/src/Resources/fall.png has changed
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/Resources/hi.png
Binary file middleware/src/Resources/hi.png has changed
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/Resources/leg.png
Binary file middleware/src/Resources/leg.png has changed
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/Resources/saut.png
Binary file middleware/src/Resources/saut.png has changed
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/bin/Release/Imgs/bend.png
Binary file middleware/src/bin/Release/Imgs/bend.png has changed
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/bin/Release/Imgs/fall.png
Binary file middleware/src/bin/Release/Imgs/fall.png has changed
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/bin/Release/Imgs/hello.png
Binary file middleware/src/bin/Release/Imgs/hello.png has changed
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/bin/Release/Imgs/jump.png
Binary file middleware/src/bin/Release/Imgs/jump.png has changed
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/bin/Release/Imgs/knee_up.png
Binary file middleware/src/bin/Release/Imgs/knee_up.png has changed
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/bin/Release/Settings.settings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/middleware/src/bin/Release/Settings.settings Thu Jun 21 16:52:56 2012 +0200
@@ -0,0 +1,42 @@
+
+
+
+
+
+ 1
+
+
+ 1
+
+
+ 127.0.0.1
+
+
+ 1000
+
+
+ 10
+
+
+ 10
+
+
+ 8080
+
+
+ 20
+
+
+ 1.5
+
+
+ 3
+
+
+ 1.7
+
+
+ 0.1
+
+
+
\ No newline at end of file
diff -r 25e71ada2a6d -r 37ebedd84755 middleware/src/bin/Release/config.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/middleware/src/bin/Release/config.txt Thu Jun 21 16:52:56 2012 +0200
@@ -0,0 +1,12 @@
+searchMinDistance:1,0
+minDistance:1,0
+connexionHost:127.0.0.1
+timerElapsing:1000
+takenPoints:10
+directionChangeTresholdXY:10
+connexionPort:8080
+imagesToShow:20
+searchMaxDistance:1,5
+maxDistance:3,0
+zeroPoint:1,9
+directionChangeTresholdZ:0,1
\ No newline at end of file