コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the MainWindow class
        /// </summary>
        public MainWindow()
        {
            // only one sensor is currently supported
            this.kinectSensor = KinectSensor.GetDefault();
            
            // set IsAvailableChanged event notifier
            this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;

            // open the sensor
            this.kinectSensor.Open();

            // set the status text
            this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText
                                                            : Properties.Resources.NoSensorStatusText;

            // open the reader for the body frames
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            // set the BodyFramedArrived event notifier
            this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived;

            
            // initialize the MainWindow
            this.InitializeComponent();

            // set our data context objects for display in UI
            //this.DataContext = this;
            
            // create a gesture detector for each body (6 bodies => 6 detectors) and create content controls to display results in the UI
            GestureResultView result = new GestureResultView(0, false, false, 0.0f);
            GestureDetector detector = new GestureDetector(this.kinectSensor, result);
            this.gestureDetector = detector;                
            
            // split gesture results across the first two columns of the content grid
            ContentControl contentControl = new ContentControl();
            contentControl.Content = this.gestureDetector.GestureResultView;
            Grid.SetColumn(contentControl, 0);
            Grid.SetRow(contentControl, 0);
            this.contentGrid.Children.Add(contentControl);
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the MainWindow class
        /// </summary>
        public MainWindow()
        {
            // only one sensor is currently supported
            this.kinectSensor = KinectSensor.GetDefault();

            // set IsAvailableChanged event notifier
            this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;

            // open the sensor
            this.kinectSensor.Open();

            // set the status text
            this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText
                                                            : Properties.Resources.NoSensorStatusText;

            // open the reader for the body frames
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            // set the BodyFramedArrived event notifier
            this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived;

            // initialize the BodyViewer object for displaying tracked bodies in the UI
            this.kinectBodyView = new KinectBodyView(this.kinectSensor);

            // initialize the gesture detection objects for our gestures
            this.gestureDetectorList = new List<GestureDetector>();

            // initialize the MainWindow
            this.InitializeComponent();

            // set our data context objects for display in UI
            this.DataContext = this;
            this.kinectBodyViewbox.DataContext = this.kinectBodyView;

            // create a gesture detector for each body (6 bodies => 6 detectors) and create content controls to display results in the UI
            int col0Row = 0;
            int col1Row = 0;
            int maxBodies = this.kinectSensor.BodyFrameSource.BodyCount;
            for (int i = 0; i < maxBodies; ++i)
            {
                GestureResultView result = new GestureResultView(i, false, false, 0.0f);
                GestureDetector detector = new GestureDetector(this.kinectSensor, result);
                this.gestureDetectorList.Add(detector);

                // split gesture results across the first two columns of the content grid
                ContentControl contentControl = new ContentControl();
                contentControl.Content = this.gestureDetectorList[i].GestureResultView;

                if (i % 2 == 0)
                {
                    // Gesture results for bodies: 0, 2, 4
                    Grid.SetColumn(contentControl, 0);
                    Grid.SetRow(contentControl, col0Row);
                    ++col0Row;
                }
                else
                {
                    // Gesture results for bodies: 1, 3, 5
                    Grid.SetColumn(contentControl, 1);
                    Grid.SetRow(contentControl, col1Row);
                    ++col1Row;
                }

                this.contentGrid.Children.Add(contentControl);
            }
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the MainWindow class
        /// </summary>
        public MainWindow()
        {
            // only one sensor is currently supported
            this.kinectSensor = KinectSensor.GetDefault();
            
            // set IsAvailableChanged event notifier
            this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;

            // open the sensor
            this.kinectSensor.Open();

            // set the status text
            this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText
                                                            : Properties.Resources.NoSensorStatusText;

            // open the reader for the body frames
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            // set the BodyFramedArrived event notifier
            this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived;

            // initialize the BodyViewer object for displaying tracked bodies in the UI
            this.kinectBodyView = new KinectBodyView(this.kinectSensor);

            // initialize the gesture detection objects for our gestures
            this.gestureDetectorList = new List<GestureDetector>();

            // initialize the MainWindow
            this.InitializeComponent();

            // set our data context objects for display in UI
            this.DataContext = this;
            this.kinectBodyViewbox.DataContext = this.kinectBodyView;

            // create a gesture detector for each body (6 bodies => 6 detectors) and create content controls to display results in the UI
            int col0Row = 0;
            int col1Row = 0;
            // int maxBodies = this.kinectSensor.BodyFrameSource.BodyCount;
            //MOdified Code
            int maxBodies = 2;
            for (int i = 0; i < maxBodies; ++i)
            {
                GestureResultView result = new GestureResultView(i, false, false, 0.0f);
                GestureDetector detector = new GestureDetector(this.kinectSensor, result);
                this.gestureDetectorList.Add(detector);                
                
                // split gesture results across the first two columns of the content grid
                ContentControl contentControl = new ContentControl();
                contentControl.Content = this.gestureDetectorList[i].GestureResultView;
                
                if (i % 2 == 0)
                {
                    // Gesture results for bodies: 0, 2, 4
                    Grid.SetColumn(contentControl, 0);
                    Grid.SetRow(contentControl, col0Row);
                    ++col0Row;
                }
                else
                {
                    // Gesture results for bodies: 1, 3, 5
                    Grid.SetColumn(contentControl, 1);
                    Grid.SetRow(contentControl, col1Row);
                    ++col1Row;
                }

                this.contentGrid.Children.Add(contentControl);
            }
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the MainWindow class
        /// </summary>
        public MainWindow()
        {
            // only one sensor is currently supported
            this.kinectSensor = KinectSensor.GetDefault();

            // set IsAvailableChanged event notifier
            this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;

            // open the sensor
            this.kinectSensor.Open();

            this._reader = kinectSensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth);
            this._reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived;

            // set the status text
            this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText
                                                            : Properties.Resources.NoSensorStatusText;

            // open the reader for the body frames
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            // set the BodyFramedArrived event notifier
            this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived;

            // initialize the BodyViewer object for displaying tracked bodies in the UI
            this.kinectBodyView = new KinectBodyView(this.kinectSensor);

            // initialize the gesture detection objects for our gestures
            this.gestureDetectorList = new List <GestureDetector>();

            // initialize the MainWindow
            this.InitializeComponent();

            // set our data context objects for display in UI
            this.DataContext = this;
            this.kinectBodyViewbox.DataContext = this.kinectBodyView;

            // connect to htk server via tcpClient
            //this.clientInterface = ClientInterface.getClientInstance();
            //clientInterface.connect();

            //Console.WriteLine("connect to the client interface \n " + clientInterface.GetHashCode() + "\n");
            //clientInterface.disconnect();

            // create a gesture detector for each body (6 bodies => 6 detectors) and create content controls to display results in the UI
            //int col0Row = 0, col1Row = 0;

            this.colorFrameWriter           = new ColorFrameWriter();
            this.depthFrameWriter           = new DepthFrameWriter();
            this.jointDataWriter            = new JointDataWriter();
            this.totalCapturedFrames_joints = 0;
            this.totalCapturedFrames_color  = 0;
            this.totalCapturedFrames_depth  = 0;
            this.framesCapturedInPhrase     = 0;
            this.phrase_indices             = new int[phrase_list.Length];

            if (File.Exists(@".\indices_state.txt"))
            {
                System.IO.StreamReader file = new System.IO.StreamReader(@".\indices_state.txt");
                String   indices_line       = file.ReadLine();
                String[] indices_states     = indices_line.Split(' ');
                for (int i = 0; i < phrase_indices.Length; i++)
                {
                    if (i >= indices_states.Length)
                    {
                        this.phrase_indices[i] = 0;
                    }
                    else
                    {
                        this.phrase_indices[i] = Int32.Parse(indices_states[i]);
                    }
                }
            }
            else
            {
                for (int i = 0; i < phrase_indices.Length; i++)
                {
                    this.phrase_indices[i] = 0;
                }
            }

            random_phrase_indices     = new int[phrase_list.Length];
            random_phrase_inx_counter = 0;
            for (int i = 0; i < phrase_list.Length; i++)
            {
                random_phrase_indices[i] = i;
            }
            new Random().Shuffle(random_phrase_indices);

            session_number = 1;

            int maxBodies = this.kinectSensor.BodyFrameSource.BodyCount;

            for (int i = 0; i < maxBodies; ++i)
            {
                GestureResultView result   = new GestureResultView(i, false, false, 0.0f);
                GestureDetector   detector = new GestureDetector(this.kinectSensor, result);
                this.gestureDetectorList.Add(detector);

                // split gesture results across the first two columns of the content grid
                ContentControl contentControl = new ContentControl();
                contentControl.Content = this.gestureDetectorList[i].GestureResultView;

                /*
                 * if (i % 2 == 0)
                 * {
                 *  // Gesture results for bodies: 0, 2, 4
                 *  Grid.SetColumn(contentControl, 0);
                 *  Grid.SetRow(contentControl, col0Row);
                 ++col0Row;
                 * }
                 * else
                 * {
                 *  // Gesture results for bodies: 1, 3, 5
                 *  Grid.SetColumn(contentControl, 1);
                 *  Grid.SetRow(contentControl, col1Row);
                 ++col1Row;
                 * }
                 *
                 * this.contentGrid.Children.Add(contentControl);*/
            }

            prevDeleteButton.Click += deletePreviousSample;
            currentPhraseName.Text  = phrase_list[current_phrase_index];

            String current_phrase = phrase_list[current_phrase_index];

            char[]   delims = { '_' };
            String[] words  = current_phrase.Split(delims);

            StringBuilder builder = new StringBuilder();

            foreach (string s in words)
            {
                builder.Append(s.ToLower()).Append(" ");
            }
            String cleanedPhrase = builder.ToString().TrimEnd(new char[] { ' ' });

            cleanedPhrase += ".png";
            //Console.WriteLine("!!!!!!!!!!!!!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" + cleanedPhrase);

            BitmapImage image = new BitmapImage();

            image.BeginInit();
            image.UriSource = new Uri(System.IO.Path.Combine(
                                          @"C:\Users\aslr\Documents\GitHub\SignLanguageRecognition\phrase-sampler-3.0\phrase_images", cleanedPhrase));
            image.EndInit();
            phraseImage.Source = image;

            phrase_name = phrase_list[current_phrase_index];

            /*clientInterface.sendData("new_phrase");
             * clientInterface.sendData(phrase_name);*/

            //String mainDir = System.IO.Path.Combine(@"C:\Users\aslr\Documents\aslr-data", phrase_name);
            //String colorDir = System.IO.Path.Combine(mainDir, "color");
            //String depthDir = System.IO.Path.Combine(mainDir, "depth");
            //Console.WriteLine("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& " + kinect.DepthStream.FrameWidth);\

            mainDir = System.IO.Path.Combine(dataWritePath, phrase_name);
            //String colorDir = System.IO.Path.Combine(mainDir, "color");
            //String depthDir = System.IO.Path.Combine(mainDir, "depth");
            System.IO.Directory.CreateDirectory(mainDir);
            //System.IO.Directory.CreateDirectory(colorDir);
            //System.IO.Directory.CreateDirectory(depthDir);

            //System.IO.Directory.CreateDirectory(mainDir);
            //System.IO.Directory.CreateDirectory(colorDir);
            //System.IO.Directory.CreateDirectory(depthDir);

            colorFrameWriter.setCurrentPhrase(phrase_name);
            depthFrameWriter.setCurrentPhrase(phrase_name);
            jointDataWriter.setCurrentPhrase(phrase_name);
        }
コード例 #5
0
        /// <summary>
        /// 初始化MainWindow类的新实例
        /// Initializes a new instance of the MainWindow class
        /// </summary>
        public MainWindow()
        {
            // only one sensor is currently supported
            //当前只有一个传感器被支持
            this.kinectSensor = KinectSensor.GetDefault();

            // set IsAvailableChanged event notifier
            //设置IsAvailableChanged事件通知程序
            this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;

            // open the sensor
            //打开kinect
            this.kinectSensor.Open();

            // set the status text
            //设置状态正文
            this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText
                                                            : Properties.Resources.NoSensorStatusText;

            // open the reader for the body frames
            //打开身体框架阅读器
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            // set the BodyFramedArrived event notifier
            // 设置BodyFramedArrived事件通知程序
            this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived;

            // initialize the BodyViewer object for displaying tracked bodies in the UI
            // 初始化BodyViewer对象以在UI中显示跟踪的实体
            this.kinectBodyView = new KinectBodyView(this.kinectSensor);

            // initialize the gesture detection objects for our gestures
            // 为我们的手势初始化手势检测对象
            this.gestureDetectorList = new List <GestureDetector>();

            // initialize the MainWindow
            // 初始化主窗口
            this.InitializeComponent();

            // set our data context objects for display in UI
            // 设置我们的数据上下文对象以在UI中显示
            this.DataContext = this;
            this.kinectBodyViewbox.DataContext = this.kinectBodyView;

            // create a gesture detector for each body (6 bodies => 6 detectors) and create content controls to display results in the UI
            // 为每个身体创建一个手势检测器(6个身体=> 6个检测器)并创建内容控件以在UI中显示结果
            int col0Row   = 0;
            int col1Row   = 0;
            int maxBodies = this.kinectSensor.BodyFrameSource.BodyCount;

            for (int i = 0; i < maxBodies; ++i)
            {
                GestureResultView result   = new GestureResultView(i, false, false, 0.0f);
                GestureDetector   detector = new GestureDetector(this.kinectSensor, result);
                this.gestureDetectorList.Add(detector);

                // split gesture results across the first two columns of the content grid
                // 在内容网格的前两列中分割手势结果
                ContentControl contentControl = new ContentControl();
                contentControl.Content = this.gestureDetectorList[i].GestureResultView;

                if (i % 2 == 0)
                {
                    // Gesture results for bodies: 0, 2, 4
                    // 身体的手势结果:0,2,4
                    Grid.SetColumn(contentControl, 0);
                    Grid.SetRow(contentControl, col0Row);
                    ++col0Row;
                }
                else
                {
                    // Gesture results for bodies: 1, 3, 5
                    //身体的手势结果:1,3,5
                    Grid.SetColumn(contentControl, 1);
                    Grid.SetRow(contentControl, col1Row);
                    ++col1Row;
                }

                this.contentGrid.Children.Add(contentControl);
            }
        }
コード例 #6
0
ファイル: MainWindow.xaml.cs プロジェクト: Thomazr/DDS
        /// <summary>
        /// Initializes a new instance of the MainWindow class
        /// </summary>
        public MainWindow()
        {
            // only one sensor is currently supported
            this.kinectSensor = KinectSensor.GetDefault();

            // open the sensor
            this.kinectSensor.Open();

            // open the reader for the body frames
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            // set the BodyFramedArrived event notifier
            this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived;

            // initialize the BodyViewer object for displaying tracked bodies in the UI
            this.kinectBodyView = new KinectBodyView(this.kinectSensor);

            // initialize the gesture detection objects for our gestures
            this.gestureDetectorList = new List<GestureDetector>();

            // initialize the MainWindow
            this.InitializeComponent();

            // set our data context objects for display in UI
            this.DataContext = this;

            // create a gesture detector for each body (6 bodies => 6 detectors) and create content controls to display results in the UI
            int maxBodies = this.kinectSensor.BodyFrameSource.BodyCount;
            for (int i = 0; i < maxBodies; ++i)
            {
                GestureResultView result = new GestureResultView(i, false, false, 0.0f);
                GestureDetector detector = new GestureDetector(this.kinectSensor, result);

                detector.GestureDetected += this.GestureDetected;
                this.gestureDetectorList.Add(detector);
            }
        }
コード例 #7
0
        public MainWindow()
        {
            main = this;

            InitializeComponent();

            options.Add(new TodoItem()
            {
                Title = "Pesquisar Voo para Paris", Color = "#ff00BCF2"
            });
            options.Add(new TodoItem()
            {
                Title = "Pesquisar Voo para Roma"
            });
            options.Add(new TodoItem()
            {
                Title = "Pesquisar Voo para Londres"
            });
            options.Add(new TodoItem()
            {
                Title = "Pesquisar Hotel para Paris"
            });
            options.Add(new TodoItem()
            {
                Title = "Pesquisar Hotel para Roma"
            });
            options.Add(new TodoItem()
            {
                Title = "Pesquisar Hotel para Londres"
            });

            lbTodoList.ItemsSource = options;

            // only one sensor is currently supported
            this.kinectSensor = KinectSensor.GetDefault();

            // set IsAvailableChanged event notifier
            this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;

            // open the sensor
            this.kinectSensor.Open();

            // set the status text
            this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText
                                                            : Properties.Resources.NoSensorStatusText;

            // open the reader for the body frames
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            // set the BodyFramedArrived event notifier
            this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived;

            // initialize the BodyViewer object for displaying tracked bodies in the UI
            this.kinectBodyView = new KinectBodyView(this.kinectSensor);

            // initialize the gesture detection objects for our gestures
            this.gestureDetectorList = new List <GestureDetector>();

            // initialize the MainWindow
            this.InitializeComponent();

            // set our data context objects for display in UI
            this.DataContext = this;
            this.kinectBodyViewbox.DataContext = this.kinectBodyView;

            // create a gesture detector for each body (6 bodies => 6 detectors) and create content controls to display results in the UI
            //int col0Row = 0;
            //int col1Row = 0;
            //int maxBodies = this.kinectSensor.BodyFrameSource.BodyCount;
            //for (int i = 0; i < maxBodies; ++i)
            //{
            GestureResultView result   = new GestureResultView(0, false, false, 0.0f);
            GestureDetector   detector = new GestureDetector(this.kinectSensor, result, this.main, circle, this.Dispatcher);

            this.gestureDetectorList.Add(detector);

            // split gesture results across the first two columns of the content grid
            ContentControl contentControl = new ContentControl();

            contentControl.Content = this.gestureDetectorList[0].GestureResultView;

            //if (i % 2 == 0)
            //{
            // Gesture results for bodies: 0, 2, 4
            Grid.SetColumn(contentControl, 0);
            Grid.SetRow(contentControl, 2);
            //++col0Row;
            //}
            //else
            //{
            // Gesture results for bodies: 1, 3, 5
            // Grid.SetColumn(contentControl, 1);
            //Grid.SetRow(contentControl, col1Row);
            // ++col1Row;
            //}

            this.contentGrid.Children.Add(contentControl);
            //}

            //init LifeCycleEvents..
            lce = new LifeCycleEvents("ASR", "FUSION", "speech-1", "acoustic", "command"); // LifeCycleEvents(string source, string target, string id, string medium, string mode)
            //mmic = new MmiCommunication("localhost",9876,"User1", "ASR");  //PORT TO FUSION - uncomment this line to work with fusion later
            mmic = new MmiCommunication("localhost", 8000, "User1", "ASR");                // MmiCommunication(string IMhost, int portIM, string UserOD, string thisModalityName)

            mmic.Send(lce.NewContextRequest());
        }
コード例 #8
0
        /// <summary>
        /// Initializes a new instance of the MainWindow class
        /// </summary>
        public MainWindow()
        {
            // only one sensor is currently supported
            this.kinectSensor = KinectSensor.GetDefault();

            // set IsAvailableChanged event notifier
            this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;

            // open the sensor
            this.kinectSensor.Open();

            // set the status text
            this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText
                                                            : Properties.Resources.NoSensorStatusText;

            // open the reader for the body frames
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            // set the BodyFramedArrived event notifier
            this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived;

            // initialize the BodyViewer object for displaying tracked bodies in the UI
            this.kinectBodyView = new KinectBodyView(this.kinectSensor);

            // initialize the MainWindow
            this.InitializeComponent();

            // set our data context objects for display in UI
            this.DataContext = this;
            this.kinectBodyViewbox.DataContext = this.kinectBodyView;

            // create a gesture detector for each body (6 bodies => 6 detectors) and create content controls to display results in the UI

            gestureResultView = new GestureResultView(false, false, 0.0f, "null");
            gestureDetector   = new GestureDetector(this.kinectSensor, gestureResultView);

            ContentControl contentControl = new ContentControl();

            contentControl.Content = this.gestureDetector.GestureResultView;

            Grid.SetColumn(contentControl, 0);
            Grid.SetRow(contentControl, 1);

            this.contentGrid.Children.Add(contentControl);

            MoveTo(0, 0);
            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromSeconds(0.1);
            timer.Tick    += timer_Tick;
            timer.Start();

            this.Abcsissa = abcsissa;
            this.Ordinate = ordinate;
            if (serialAttached == true)
            {
                this.serialport     = new SerialPort();
                serialport.PortName = "COM3";
                serialport.Open();
                serialport.BaudRate = 57600;
            }
        }//main window
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the MainWindow class
        /// </summary>
        public MainWindow()
        {
            // only one sensor is currently supported
            this.kinectSensor = KinectSensor.GetDefault();
            
            // set IsAvailableChanged event notifier
            this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;

            // open the sensor
            this.kinectSensor.Open();

            this._reader = kinectSensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth);
            this._reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived;

            // set the status text
            this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText
                                                            : Properties.Resources.NoSensorStatusText;

            // open the reader for the body frames
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            // set the BodyFramedArrived event notifier
            this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived;

            // initialize the BodyViewer object for displaying tracked bodies in the UI
            this.kinectBodyView = new KinectBodyView(this.kinectSensor);

            // initialize the gesture detection objects for our gestures
            this.gestureDetectorList = new List<GestureDetector>();

            // initialize the MainWindow
            this.InitializeComponent();

            // set our data context objects for display in UI
            this.DataContext = this;
            this.kinectBodyViewbox.DataContext = this.kinectBodyView;

            // connect to htk server via tcpClient
            //this.clientInterface = ClientInterface.getClientInstance();
            //clientInterface.connect();

            //Console.WriteLine("connect to the client interface \n " + clientInterface.GetHashCode() + "\n");            
            //clientInterface.disconnect();

            // create a gesture detector for each body (6 bodies => 6 detectors) and create content controls to display results in the UI
            //int col0Row = 0, col1Row = 0;

            this.colorFrameWriter = new ColorFrameWriter();
            this.depthFrameWriter = new DepthFrameWriter();
            this.jointDataWriter = new JointDataWriter();
            this.totalCapturedFrames_joints = 0;
            this.totalCapturedFrames_color = 0;
            this.totalCapturedFrames_depth = 0;

            session_number = 1;

            int maxBodies = this.kinectSensor.BodyFrameSource.BodyCount;
            for (int i = 0; i < maxBodies; ++i)
            {
                GestureResultView result = new GestureResultView(i, false, false, 0.0f);
                GestureDetector detector = new GestureDetector(this.kinectSensor, result);
                this.gestureDetectorList.Add(detector);                
                
                // split gesture results across the first two columns of the content grid
                ContentControl contentControl = new ContentControl();
                contentControl.Content = this.gestureDetectorList[i].GestureResultView;
                /*
                if (i % 2 == 0)
                {
                    // Gesture results for bodies: 0, 2, 4
                    Grid.SetColumn(contentControl, 0);
                    Grid.SetRow(contentControl, col0Row);
                    ++col0Row;
                }
                else
                {
                    // Gesture results for bodies: 1, 3, 5
                    Grid.SetColumn(contentControl, 1);
                    Grid.SetRow(contentControl, col1Row);
                    ++col1Row;
                }

                this.contentGrid.Children.Add(contentControl);*/
            }

            prevDeleteButton.Click += deletePreviousSample;
            currentPhraseName.Text = phrase_list[current_phrase_index];

            String current_phrase = phrase_list[current_phrase_index];
            char[] delims = { '_' };
            String[] words = current_phrase.Split(delims);

            StringBuilder builder = new StringBuilder();
            foreach (string s in words)
            {
                builder.Append(s.ToLower()).Append(" ");
            }
            String cleanedPhrase = builder.ToString().TrimEnd(new char[] { ' ' });
            cleanedPhrase += ".png";
            //Console.WriteLine("!!!!!!!!!!!!!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" + cleanedPhrase);

            BitmapImage image = new BitmapImage();
            image.BeginInit();
            image.UriSource = new Uri(System.IO.Path.Combine(
                @"C:\Users\aslr\Documents\GitHub\SignLanguageRecognition\phrase-sampler-2.0\phrase_images", cleanedPhrase));
            image.EndInit();
            phraseImage.Source = image;

            phrase_name = phrase_list[current_phrase_index];
            /*clientInterface.sendData("new_phrase");
            clientInterface.sendData(phrase_name);*/

            //String mainDir = System.IO.Path.Combine(@"C:\Users\aslr\Documents\aslr-data", phrase_name);
            //String colorDir = System.IO.Path.Combine(mainDir, "color");
            //String depthDir = System.IO.Path.Combine(mainDir, "depth");
            //Console.WriteLine("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& " + kinect.DepthStream.FrameWidth);\

            mainDir = System.IO.Path.Combine(dataWritePath, phrase_name);
            //String colorDir = System.IO.Path.Combine(mainDir, "color");
            //String depthDir = System.IO.Path.Combine(mainDir, "depth");
            System.IO.Directory.CreateDirectory(mainDir);
            //System.IO.Directory.CreateDirectory(colorDir);
            //System.IO.Directory.CreateDirectory(depthDir);

            //System.IO.Directory.CreateDirectory(mainDir);
            //System.IO.Directory.CreateDirectory(colorDir);
            //System.IO.Directory.CreateDirectory(depthDir);

            colorFrameWriter.setCurrentPhrase(phrase_name);
            depthFrameWriter.setCurrentPhrase(phrase_name);
            jointDataWriter.setCurrentPhrase(phrase_name);
        }
コード例 #10
0
        /// <summary>
        /// Initializes a new instance of the MainWindow class
        /// </summary>
        public MainWindow()
        {
            // only one sensor is currently supported
            this.kinectSensor = KinectSensor.GetDefault();
            
            // set IsAvailableChanged event notifier
            this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;

            // open the sensor
            this.kinectSensor.Open();

            // set the status text
            this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText
                                                            : Properties.Resources.NoSensorStatusText;

            // open the reader for the body frames
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            // set the BodyFramedArrived event notifier
            this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived;

            // initialize the BodyViewer object for displaying tracked bodies in the UI
            this.kinectBodyView = new KinectBodyView(this.kinectSensor);

            // initialize the gesture detection objects for our gestures
            this.gestureDetectorList = new List<GestureDetector>();

            // initialize the MainWindow
            this.InitializeComponent();

            // set our data context objects for display in UI
            this.DataContext = this;
            this.kinectBodyViewbox.DataContext = this.kinectBodyView;

            // connect to htk server via tcpClient
            this.clientInterface = ClientInterface.getClientInstance();
            clientInterface.connect();

            Console.WriteLine("connect to the client interface \n " + clientInterface.GetHashCode() + "\n");            
            //clientInterface.disconnect();

            // create a gesture detector for each body (6 bodies => 6 detectors) and create content controls to display results in the UI
            //int col0Row = 0, col1Row = 0;

            int maxBodies = this.kinectSensor.BodyFrameSource.BodyCount;
            for (int i = 0; i < maxBodies; ++i)
            {
                GestureResultView result = new GestureResultView(i, false, false, 0.0f);
                GestureDetector detector = new GestureDetector(this.kinectSensor, result);
                this.gestureDetectorList.Add(detector);                
                
                // split gesture results across the first two columns of the content grid
                ContentControl contentControl = new ContentControl();
                contentControl.Content = this.gestureDetectorList[i].GestureResultView;
                /*
                if (i % 2 == 0)
                {
                    // Gesture results for bodies: 0, 2, 4
                    Grid.SetColumn(contentControl, 0);
                    Grid.SetRow(contentControl, col0Row);
                    ++col0Row;
                }
                else
                {
                    // Gesture results for bodies: 1, 3, 5
                    Grid.SetColumn(contentControl, 1);
                    Grid.SetRow(contentControl, col1Row);
                    ++col1Row;
                }

                this.contentGrid.Children.Add(contentControl);*/
            }

            prevDeleteButton.Click += deletePreviousSample;
            currentPhraseName.Text = (current_phrase_index+1) + " " + phrase_list[current_phrase_index];
            phrase_name = phrase_list[current_phrase_index];
            clientInterface.sendData("new_phrase");
            clientInterface.sendData(phrase_name);
            
        }
コード例 #11
0
        /// <summary>
        /// Initializes a new instance of the MainWindow class
        /// </summary>
        public MainWindow()
        {
            // only one sensor is currently supported
            this.kinectSensor = KinectSensor.GetDefault();

            // set IsAvailableChanged event notifier
            this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;

            // open the sensor
            this.kinectSensor.Open();

            // set the status text
            this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText
                                                            : Properties.Resources.NoSensorStatusText;

            // open the reader for the body frames
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            // set the BodyFramedArrived event notifier
            this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived;

            // initialize the BodyViewer object for displaying tracked bodies in the UI
            this.kinectBodyView = new KinectBodyView(this.kinectSensor);

            // initialize the gesture detection objects for our gestures
            this.gestureDetectorList = new List <GestureDetector>();

            // initialize the MainWindow
            this.InitializeComponent();

            // set our data context objects for display in UI
            this.DataContext = this;
            this.kinectBodyViewbox.DataContext = this.kinectBodyView;

            // create a gesture detector for each body (6 bodies => 6 detectors) and create content controls to display results in the UI
            int col0Row   = 0;
            int col1Row   = 0;
            int maxBodies = this.kinectSensor.BodyFrameSource.BodyCount;

            for (int i = 0; i < maxBodies; ++i)
            {
                GestureResultView result = new GestureResultView(i, false, false, 0.0f);

                //  foreach (var database in GestureHelper.gestures)
                //  {
                GestureDetector detector = new GestureDetector(this.kinectSensor, result);
                this.gestureDetectorList.Add(detector);
                // }

                // split gesture results across the first two columns of the content grid
                ContentControl contentControl = new ContentControl();
                contentControl.Content = this.gestureDetectorList[i].GestureResultView;

                if (i % 2 == 0)
                {
                    // Gesture results for bodies: 0, 2, 4
                    Grid.SetColumn(contentControl, 0);
                    Grid.SetRow(contentControl, col0Row);
                    ++col0Row;
                }
                else
                {
                    // Gesture results for bodies: 1, 3, 5
                    Grid.SetColumn(contentControl, 1);
                    Grid.SetRow(contentControl, col1Row);
                    ++col1Row;
                }

                this.contentGrid.Children.Add(contentControl);
            }

            // Face detection

            _faceSource = new FaceFrameSource(kinectSensor, 0,
                                              FaceFrameFeatures.BoundingBoxInColorSpace |
                                              FaceFrameFeatures.Happy |
                                              FaceFrameFeatures.LeftEyeClosed |
                                              FaceFrameFeatures.MouthOpen |
                                              FaceFrameFeatures.FaceEngagement |
                                              FaceFrameFeatures.LookingAway |
                                              FaceFrameFeatures.PointsInColorSpace |
                                              FaceFrameFeatures.RightEyeClosed);
            _faceReader = _faceSource.OpenReader();
            _faceReader.FrameArrived += FaceReader_FrameArrived;

            this.sp = new SerialPort(Properties.Settings.Default.ComPort, Properties.Settings.Default.Baudrate, Parity.None, 8, StopBits.One);
        }