--- 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)