29 using Microsoft.Kinect; |
29 using Microsoft.Kinect; |
30 using System.Resources; |
30 using System.Resources; |
31 using System.Reflection; |
31 using System.Reflection; |
32 using System.Timers; |
32 using System.Timers; |
33 using System.Configuration; |
33 using System.Configuration; |
|
34 using System.IO; |
34 |
35 |
35 namespace Trakers.Debug |
36 namespace Trakers.Debug |
36 { |
37 { |
37 public partial class DebugWindow : Window |
38 public partial class DebugWindow : Window |
38 { |
39 { |
99 maxDist = 4.0f; |
100 maxDist = 4.0f; |
100 zeroPoint = 1.7f; |
101 zeroPoint = 1.7f; |
101 connexionHost = "127.0.0.1"; |
102 connexionHost = "127.0.0.1"; |
102 connexionPort = 80; |
103 connexionPort = 80; |
103 timerElapsing = 1000; |
104 timerElapsing = 1000; |
|
105 imagesToShow = 20; |
|
106 takenPoints = 10; |
|
107 directionChangeTresholdXY = 10; |
|
108 directionChangeTresholdZ = 0.01f; |
|
109 /*minDistHands = 1.0f; |
|
110 maxDistHands = 5.5f; |
|
111 minDist = 1.0f; |
|
112 maxDist = 6.0f; |
|
113 zeroPoint = 1.7f; |
|
114 connexionHost = "127.0.0.1"; |
|
115 connexionPort = 80; |
|
116 timerElapsing = 1000; |
104 imagesToShow = 25; |
117 imagesToShow = 25; |
105 takenPoints = 10; |
118 takenPoints = 10; |
106 directionChangeTresholdXY = 10; |
119 directionChangeTresholdXY = 10; |
107 directionChangeTresholdZ = 0.01f; |
120 directionChangeTresholdZ = 0.01f;*/ |
108 } |
121 } |
109 |
122 |
110 //On charge la fenêtre de paramètres. |
123 //On charge la fenêtre de paramètres. |
111 param = new DebugParameters(this); |
124 param = new DebugParameters(this); |
112 |
125 |
253 Gestures.Source = null; |
266 Gestures.Source = null; |
254 } |
267 } |
255 } |
268 } |
256 } |
269 } |
257 |
270 |
|
271 /*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) |
|
272 { |
|
273 if(C1) |
|
274 R0.Fill = System.Windows.Media.Brushes.Blue; |
|
275 else |
|
276 R0.Fill = System.Windows.Media.Brushes.DarkGray; |
|
277 |
|
278 if (C2) |
|
279 R1.Fill = System.Windows.Media.Brushes.Blue; |
|
280 else |
|
281 R1.Fill = System.Windows.Media.Brushes.DarkGray; |
|
282 |
|
283 if (C3) |
|
284 R2.Fill = System.Windows.Media.Brushes.Blue; |
|
285 else |
|
286 R2.Fill = System.Windows.Media.Brushes.DarkGray; |
|
287 |
|
288 if (C4) |
|
289 R3.Fill = System.Windows.Media.Brushes.Blue; |
|
290 else |
|
291 R3.Fill = System.Windows.Media.Brushes.DarkGray; |
|
292 |
|
293 if (C5) |
|
294 R4.Fill = System.Windows.Media.Brushes.Blue; |
|
295 else |
|
296 R4.Fill = System.Windows.Media.Brushes.DarkGray; |
|
297 |
|
298 if (C6) |
|
299 R5.Fill = System.Windows.Media.Brushes.Blue; |
|
300 else |
|
301 R5.Fill = System.Windows.Media.Brushes.DarkGray; |
|
302 |
|
303 if (C7) |
|
304 R6.Fill = System.Windows.Media.Brushes.Blue; |
|
305 else |
|
306 R6.Fill = System.Windows.Media.Brushes.DarkGray; |
|
307 |
|
308 if (C8) |
|
309 R7.Fill = System.Windows.Media.Brushes.Blue; |
|
310 else |
|
311 R7.Fill = System.Windows.Media.Brushes.DarkGray; |
|
312 |
|
313 if (C9) |
|
314 R8.Fill = System.Windows.Media.Brushes.Blue; |
|
315 else |
|
316 R8.Fill = System.Windows.Media.Brushes.DarkGray; |
|
317 |
|
318 if (C10) |
|
319 R9.Fill = System.Windows.Media.Brushes.Blue; |
|
320 else |
|
321 R9.Fill = System.Windows.Media.Brushes.DarkGray; |
|
322 |
|
323 if (C11) |
|
324 R10.Fill = System.Windows.Media.Brushes.Blue; |
|
325 else |
|
326 R10.Fill = System.Windows.Media.Brushes.DarkGray; |
|
327 }*/ |
|
328 |
258 /* |
329 /* |
259 * Affiche la distance de l'utilisateur dans le rendu visuel. |
330 * Affiche la distance de l'utilisateur dans le rendu visuel. |
260 * Sous forme de nombre en m et de rectangles changeant de couleur en fonction de la distance. |
331 * Sous forme de nombre en m et de rectangles changeant de couleur en fonction de la distance. |
261 */ |
332 */ |
262 public void showDistance(float proximity) |
333 public void showDistance(float proximity) |
639 refreshImage = false; |
710 refreshImage = false; |
640 _timer.Start(); |
711 _timer.Start(); |
641 Bitmap bitmap = null; |
712 Bitmap bitmap = null; |
642 //S'il s'agit de telle ou telle gesture, on prend l'image correspondante dans les ressources, |
713 //S'il s'agit de telle ou telle gesture, on prend l'image correspondante dans les ressources, |
643 //on la convertit et on l'affiche. |
714 //on la convertit et on l'affiche. |
|
715 |
644 switch (gesture) |
716 switch (gesture) |
645 { |
717 { |
646 case "SWIPE-LEFT": bitmap = getImage(imgLocation + "\\swipe_left.png"); |
718 case "SWIPE-LEFT": bitmap = getImage(imgLocation + "\\swipe_left.png"); |
647 break; |
719 break; |
648 case "SWIPE-RIGHT": bitmap = getImage(imgLocation + "\\swipe_right.png"); |
720 case "SWIPE-RIGHT": bitmap = getImage(imgLocation + "\\swipe_right.png"); |
657 break; |
729 break; |
658 case "PULL-LEFT": bitmap = getImage(imgLocation + "\\pull_left.png"); |
730 case "PULL-LEFT": bitmap = getImage(imgLocation + "\\pull_left.png"); |
659 break; |
731 break; |
660 case "PULL-BOTH": bitmap = getImage(imgLocation + "\\pull_both.png"); |
732 case "PULL-BOTH": bitmap = getImage(imgLocation + "\\pull_both.png"); |
661 break; |
733 break; |
662 case "WAVE": bitmap = getImage(imgLocation + "\\wave.png"); |
734 case "WAVE": bitmap = getImage(imgLocation + "\\hello.png"); |
663 break; |
735 break; |
664 case "BEND": bitmap = getImage(imgLocation + "\\bend.png"); |
736 case "BEND": bitmap = getImage(imgLocation + "\\bend.png"); |
665 break; |
737 break; |
666 case "CROSS": bitmap = getImage(imgLocation + "\\cross.png"); |
|
667 break; |
|
668 case "KNEE-UP": bitmap = getImage(imgLocation + "\\knee_up.png"); |
738 case "KNEE-UP": bitmap = getImage(imgLocation + "\\knee_up.png"); |
|
739 break; |
|
740 case "JUMP": bitmap = getImage(imgLocation + "\\jump.png"); |
|
741 break; |
|
742 case "FALL": bitmap = getImage(imgLocation + "\\fall.png"); |
669 break; |
743 break; |
670 } |
744 } |
671 Gestures.Source = CreateBitmapSourceFromBitmap(bitmap); |
745 Gestures.Source = CreateBitmapSourceFromBitmap(bitmap); |
672 } |
746 } |
673 |
747 |
727 minDistHands >= maxDistHands || zeroPoint < maxDistHands || minDistHands > minDist || |
801 minDistHands >= maxDistHands || zeroPoint < maxDistHands || minDistHands > minDist || |
728 zeroPoint >= maxDist || connexionPort < 0 || timerElapsing < 0 || imagesToShow < 1 || |
802 zeroPoint >= maxDist || connexionPort < 0 || timerElapsing < 0 || imagesToShow < 1 || |
729 takenPoints <= 0 || directionChangeTresholdXY < 0 || directionChangeTresholdZ < 0) |
803 takenPoints <= 0 || directionChangeTresholdXY < 0 || directionChangeTresholdZ < 0) |
730 { |
804 { |
731 ExceptionLbl.Content = rm.GetString("loadParametersIncorrect"); |
805 ExceptionLbl.Content = rm.GetString("loadParametersIncorrect"); |
|
806 return false; |
|
807 } |
|
808 return true; |
|
809 }*/ |
|
810 |
|
811 public bool loadParameters() |
|
812 { |
|
813 try |
|
814 { |
|
815 String[] lines = System.IO.File.ReadAllLines("config.txt"); |
|
816 |
|
817 minDistHands = float.Parse(lines[0].Split(':')[1]); |
|
818 minDist = float.Parse(lines[1].Split(':')[1]); |
|
819 connexionHost = lines[2].Split(':')[1]; |
|
820 timerElapsing = int.Parse(lines[3].Split(':')[1]); |
|
821 takenPoints = int.Parse(lines[4].Split(':')[1]); |
|
822 directionChangeTresholdXY = int.Parse(lines[5].Split(':')[1]); |
|
823 connexionPort = int.Parse(lines[6].Split(':')[1]); |
|
824 imagesToShow = int.Parse(lines[7].Split(':')[1]); |
|
825 maxDistHands = float.Parse(lines[8].Split(':')[1]); |
|
826 maxDist = float.Parse(lines[9].Split(':')[1]); |
|
827 zeroPoint = float.Parse(lines[10].Split(':')[1]); |
|
828 directionChangeTresholdZ = float.Parse(lines[11].Split(':')[1]); |
|
829 } |
|
830 catch (Exception e) |
|
831 { |
|
832 StreamWriter SW; |
|
833 try |
|
834 { |
|
835 SW = File.CreateText("ErrorFile.txt"); |
|
836 SW.WriteLine(e.Message); |
|
837 SW.Close(); |
|
838 } |
|
839 catch { } |
|
840 |
|
841 return false; |
|
842 } |
|
843 |
|
844 if (maxDistHands <= 0f || minDistHands <= 0f || maxDistHands > maxDist || minDistHands > maxDist || |
|
845 minDistHands >= maxDistHands || zeroPoint < maxDistHands || minDistHands > minDist || |
|
846 zeroPoint >= maxDist || connexionPort < 0 || timerElapsing < 0 || imagesToShow < 1 || |
|
847 takenPoints <= 0 || directionChangeTresholdXY < 0 || directionChangeTresholdZ < 0) |
|
848 { |
|
849 ExceptionLbl.Content = rm.GetString("loadParametersIncorrect"); |
|
850 |
|
851 StreamWriter SW; |
|
852 try |
|
853 { |
|
854 SW = File.CreateText("ErrorFile.txt"); |
|
855 if (maxDistHands <= 0f) { SW.WriteLine("searchMaxDistance <= 0"); } |
|
856 if (minDistHands <= 0f) { SW.WriteLine("minDistance <= 0"); } |
|
857 if (maxDistHands > maxDist) { SW.WriteLine("searchMaxDistance > maxDistance"); } |
|
858 if (minDistHands > maxDist) { SW.WriteLine("searchMinDistance > maxDistance"); } |
|
859 if (minDistHands >= maxDistHands) { SW.WriteLine("searchMinDistance >= searchMaxDistance"); } |
|
860 if (zeroPoint < maxDistHands) { SW.WriteLine("zeroPoint < searchMaxDistance"); } |
|
861 if (minDistHands > minDist) { SW.WriteLine("searchMinDistance > minDistance"); } |
|
862 if (zeroPoint >= maxDist) { SW.WriteLine("zeroPoint >= maxDistance"); } |
|
863 if (connexionPort < 0) { SW.WriteLine("connexionPort < 0"); } |
|
864 if (timerElapsing < 0) { SW.WriteLine("timerElapsing < 0"); } |
|
865 if (imagesToShow < 1) { SW.WriteLine("imagesToShow < 1"); } |
|
866 if (takenPoints <= 0) { SW.WriteLine("takenPoints <= 0"); } |
|
867 if (directionChangeTresholdXY < 0) { SW.WriteLine("directionChangeTresholdXY < 0"); } |
|
868 if (directionChangeTresholdZ < 0) { SW.WriteLine("directionChangeTresholdZ < 0"); } |
|
869 SW.Close(); |
|
870 Console.WriteLine("Error File Created SucacessFully"); |
|
871 } |
|
872 catch (Exception){} |
|
873 |
732 return false; |
874 return false; |
733 } |
875 } |
734 return true; |
876 return true; |
735 } |
877 } |
736 |
878 |
832 } |
974 } |
833 public void setOn(bool _on) |
975 public void setOn(bool _on) |
834 { |
976 { |
835 on = _on; |
977 on = _on; |
836 } |
978 } |
837 public void setQuitMenu(MenuItem quitMenu) |
979 /*public void setQuitMenu(MenuItem quitMenu) |
838 { |
980 { |
839 QuitMenu = quitMenu; |
981 QuitMenu = quitMenu; |
840 } |
982 } |
841 public void setParametersWindow(DebugParameters parameters) |
983 public void setParametersWindow(DebugParameters parameters) |
842 { |
984 { |
843 param = parameters; |
985 param = parameters; |
844 } |
986 } |
845 public void setParamMenu(MenuItem parameters) |
987 public void setParamMenu(MenuItem parameters) |
846 { |
988 { |
847 ParamMenu = parameters; |
989 ParamMenu = parameters; |
848 } |
990 }*/ |
849 |
991 |
850 public float getMinDistHands() |
992 public float getMinDistHands() |
851 { |
993 { |
852 return minDistHands; |
994 return minDistHands; |
853 } |
995 } |