Esempio n. 1
0
        public Dictionary <String, GesturePackage> loadGesture()
        {
            Dictionary <String, GesturePackage> gestureDic = new Dictionary <string, GesturePackage>();
            String txt_path = String.Format("{0}/gestures.kges", dir_path);

            if (File.Exists(txt_path))
            {
                //LinkedList<String> content = new LinkedList<string>();
                using (StreamReader reader = new StreamReader(txt_path)) {
                    String         input        = "";
                    int            line_counter = 0;
                    GesturePackage ges_pack     = null;
                    while ((input = reader.ReadLine()) != null)
                    {
                        //content.AddLast(input);
                        String[] str_array = input.Split(delimChar);
                        if (line_counter % 4 == 0)
                        {
                            ges_pack = new GesturePackage(str_array[0]);
                        }
                        foreach (String str in str_array)
                        {
                            if (line_counter % 4 == 1 && ges_pack != null)
                            {
                                string[] right_coordinates = str.Split(':');
                                ges_pack.setRightCoordinates(new CoordinateContainer(Double.Parse(right_coordinates[0]), Double.Parse(right_coordinates[1]), ges_pack.getName()));
                            }
                            else if (line_counter % 4 == 2 && ges_pack != null)
                            {
                                string[] left_coordinates = str.Split(':');
                                ges_pack.setLeftCoordinates(new CoordinateContainer(Double.Parse(left_coordinates[0]), Double.Parse(left_coordinates[1]), ges_pack.getName()));
                            }
                        }
                        Console.WriteLine(input);

                        if (!gestureDic.ContainsKey(ges_pack.getName()))
                        {
                            gestureDic.Add(ges_pack.getName(), ges_pack);
                        }
                        else
                        {
                            gestureDic[ges_pack.getName()] = ges_pack;
                        }
                        line_counter++;
                    }
                    reader.Close();
                }
            }
            return(gestureDic);
        }
Esempio n. 2
0
        void OnScrollViewButtonClick(Object sender, RoutedEventArgs e)
        {
            KinectTileButton btn = (KinectTileButton)sender;

            selectedToken = btn.Content.ToString();
            Console.WriteLine(selectedToken);
            //Back to the main windows
            MainWindow     main = new MainWindow();
            GesturePackage pk   = new GesturePackage(selectedToken);

            pk.setLeftCoordinates(left_coordinates);
            pk.setRightCoordinates(right_coordinates);
            Clean();
            this.Close();
            main.OpenMain(pk);
        }
Esempio n. 3
0
        public Dictionary<String, GesturePackage> loadGesture()
        {
            Dictionary<String, GesturePackage> gestureDic = new Dictionary<string, GesturePackage>();
            String txt_path = String.Format("{0}/gestures.kges", dir_path);
            if (File.Exists(txt_path)) {
                //LinkedList<String> content = new LinkedList<string>();
                using (StreamReader reader = new StreamReader(txt_path)) {
                    String input= "";
                    int line_counter = 0;
                    GesturePackage ges_pack = null;
                    while ((input = reader.ReadLine()) != null) {
                        //content.AddLast(input);
                        String[] str_array = input.Split(delimChar);
                        if (line_counter % 4 == 0)
                        {
                            ges_pack = new GesturePackage(str_array[0]);
                        }
                        foreach(String str in str_array){
                            if (line_counter % 4 == 1 && ges_pack != null) {
                                string[] right_coordinates = str.Split(':');
                                ges_pack.setRightCoordinates(new CoordinateContainer(Double.Parse(right_coordinates[0]), Double.Parse(right_coordinates[1]), ges_pack.getName()));

                            }
                            else if (line_counter % 4 == 2 && ges_pack != null)
                            {
                                string[] left_coordinates = str.Split(':');
                                ges_pack.setLeftCoordinates(new CoordinateContainer(Double.Parse(left_coordinates[0]), Double.Parse(left_coordinates[1]), ges_pack.getName()));
                            }
                        }
                        Console.WriteLine(input);

                        if (!gestureDic.ContainsKey(ges_pack.getName()))
                        {
                            gestureDic.Add(ges_pack.getName(), ges_pack);
                        }
                        else
                        {
                            gestureDic[ges_pack.getName()] = ges_pack;
                        }
                        line_counter++;
                    }
                    reader.Close();
                }
            }
            return gestureDic;
        }
Esempio n. 4
0
        /*
         * Get everything initialized
         */
        public void Initialize()
        {
            if (kinectSensor == null)
            {
                return;
            }

            kinectSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
            kinectSensor.ColorFrameReady += kinectRuntime_ColorFrameReady;

            kinectSensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);
            kinectSensor.DepthFrameReady += kinectSensor_DepthFrameReady;

            kinectSensor.SkeletonStream.Enable(new TransformSmoothParameters
            {
                Smoothing          = 0.5f,
                Correction         = 0.5f,
                Prediction         = 0.5f,
                JitterRadius       = 0.05f,
                MaxDeviationRadius = 0.04f
            });
            kinectSensor.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady;

            skeletonDisplayManager = new SkeletonDisplayManager(kinectSensor, kinectCanvas);
            //Add keywords that you wan to detect
            //v_commander = new VoiceCommander("record", "stop", "fly away", "flapping", "start", "finish", "write");

            kinectSensor.Start();
            //kinectDisplay.DataContext = colorManager;

            //v_commander.OrderDetected += voiceCommander_OrderDetected;
            //StartVoiceCommander();

            Dictionary <string, GesturePackage> gestureDic = fileManager.loadGesture();

            GesturePackage[] values = new GesturePackage[gestureDic.Values.Count];
            gestureDic.Values.CopyTo(values, 0);

            foreach (GesturePackage package in values)
            {
                gesture1_left.Add(package.getLeftCoordinates()[0]);
                gesture1_right.Add(package.getRightCoordinates()[0]);
            }
        }
Esempio n. 5
0
 public void OpenMain(GesturePackage package)
 {
     fileManager.saveGesture(package.getName(), package.getRightCoordinates(), package.getLeftCoordinates());
     this.Show();
 }
 void OnScrollViewButtonClick(Object sender, RoutedEventArgs e)
 {
     KinectTileButton btn = (KinectTileButton)sender;
     selectedToken = btn.Content.ToString();
     Console.WriteLine(selectedToken);
     //Back to the main windows
     MainWindow main = new MainWindow();
     GesturePackage pk = new GesturePackage(selectedToken);
     pk.setLeftCoordinates(left_coordinates);
     pk.setRightCoordinates(right_coordinates);
     Clean();
     this.Close();
     main.OpenMain(pk);
 }
Esempio n. 7
0
 public void OpenMain(GesturePackage package)
 {
     fileManager.saveGesture(package.getName(), package.getRightCoordinates(), package.getLeftCoordinates());
     this.Show();
 }
Esempio n. 8
0
        /*
         * Get everything initialized
         */
        public void Initialize()
        {
            if (kinectSensor == null)
                return;

            kinectSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
            kinectSensor.ColorFrameReady += kinectRuntime_ColorFrameReady;

            kinectSensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);
            kinectSensor.DepthFrameReady += kinectSensor_DepthFrameReady;

            kinectSensor.SkeletonStream.Enable(new TransformSmoothParameters
            {
                Smoothing = 0.5f,
                Correction = 0.5f,
                Prediction = 0.5f,
                JitterRadius = 0.05f,
                MaxDeviationRadius = 0.04f
            });
            kinectSensor.SkeletonFrameReady += kinectRuntime_SkeletonFrameReady;

            skeletonDisplayManager = new SkeletonDisplayManager(kinectSensor, kinectCanvas);
            //Add keywords that you wan to detect
            //v_commander = new VoiceCommander("record", "stop", "fly away", "flapping", "start", "finish", "write");

            kinectSensor.Start();
            //kinectDisplay.DataContext = colorManager;

            //v_commander.OrderDetected += voiceCommander_OrderDetected;
            //StartVoiceCommander();

            Dictionary<string, GesturePackage> gestureDic = fileManager.loadGesture();
            GesturePackage[] values = new GesturePackage[gestureDic.Values.Count];
            gestureDic.Values.CopyTo(values, 0);

            foreach (GesturePackage package in values)
            {
                gesture1_left.Add(package.getLeftCoordinates()[0]);
                gesture1_right.Add(package.getRightCoordinates()[0]);
            }
        }