--- 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<Joint> joints = new List<Joint>();
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;
+ }
}
}