Пример #1
0
        /// <summary>
        /// Runs every time our 2D coordinates are ready.
        /// </summary>
        /// <param name="sender">The sender object</param>
        /// <param name="a">Skeleton 2Ddata Coord Event Args</param>
        private void NuiSkeleton2DdataCoordReady(object sender, Skeleton2DdataCoordEventArgs a)
        {
            currentBufferFrame.Text = _video.Count.ToString();

            // We need a sensible number of frames before we start attempting to match gestures against remembered sequences
            if (_video.Count > MinimumFrames && _capturing == false)
            {
                ////Debug.WriteLine("Reading and video.Count=" + video.Count);
                string s = _dtw.Recognize(_video);
                results.Text = "Recognised as: " + s;
                if (!s.Contains("__UNKNOWN"))
                {
                    // There was no match so reset the buffer
                    _video        = new ArrayList();
                    textBox2.Text = textBox2.Text + " " + s.Substring(1);
                    //if ()
                    //{
                    pBuilder.ClearContent();
                    pBuilder.AppendText(s.Substring(1));
                    sSynth.Speak(pBuilder);
                    //}
                }
            }

            // Ensures that we remember only the last x frames
            if (_video.Count > BufferSize)
            {
                // If we are currently capturing and we reach the maximum buffer size then automatically store
                if (_capturing)
                {
                    DtwStoreClick(null, null);
                }
                else
                {
                    // Remove the first frame in the buffer
                    _video.RemoveAt(0);
                }
            }

            // Decide which skeleton frames to capture. Only do so if the frames actually returned a number.
            // For some reason my Kinect/PC setup didn't always return a double in range (i.e. infinity) even when standing completely within the frame.
            // TODO Weird. Need to investigate this
            if (!double.IsNaN(a.GetPoint(0).X))
            {
                // Optionally register only 1 frame out of every n
                _flipFlop = (_flipFlop + 1) % Ignore;
                if (_flipFlop == 0)
                {
                    _video.Add(a.GetCoords());
                }
            }

            // Update the debug window with Sequences information
            //dtwTextOutput.Text = _dtw.RetrieveText();
        }
Пример #2
0
        /// <summary>
        /// Runs every time our 2D coordinates are ready.  每次我们的2D坐标准备就运行。
        /// </summary>
        /// <param name="sender">The sender object</param>
        /// <param name="a">Skeleton 2Ddata Coord Event Args</param>
        private void NuiSkeleton2DdataCoordReady(object sender, Skeleton2DdataCoordEventArgs a)
        {
            currentBufferFrame.Text = _video.Count.ToString();
            // 在我们开始尝试将手势与记忆序列匹配之前,我们需要合理数量的帧
            // We need a sensible number of frames before we start attempting to match gestures against remembered sequences
            if (_video.Count > MinimumFrames && _capturing == false)
            {
                ////Debug.WriteLine("Reading and video.Count=" + video.Count);
                string s = _dtw.Recognize(_video);
                results.Text = "Recognised as: " + s;
                if (!s.Contains("__UNKNOWN"))
                {
                    // There was no match so reset the buffer  没有匹配,所以重置缓冲区
                    _video = new ArrayList();
                }
            }

            // Ensures that we remember only the last x frames  确保我们只记住最后的x帧
            if (_video.Count > BufferSize)
            {
                // If we are currently capturing and we reach the maximum buffer size then automatically store
                // 如果我们正在捕获并且达到最大缓冲区大小,则自动存储
                if (_capturing)
                {
                    DtwStoreClick(null, null);
                }
                else
                {
                    // Remove the first frame in the buffer  删除缓冲区中的第一帧
                    _video.RemoveAt(0);
                }
            }

            // Decide which skeleton frames to capture. Only do so if the frames actually returned a number.
            // For some reason my Kinect/PC setup didn't always return a double in range (i.e. infinity) even when standing completely within the frame.
            // TODO Weird. Need to investigate this
            // 确定要捕获的骨架帧。 只有在帧实际返回一个数字时才这样做。
            // 出于某种原因,即使完全站在画面内,我的Kinect / PC设置并不总是返回双倍范围(即无限远)。
            // 需要对此进行调查

            if (!double.IsNaN(a.GetPoint(0).X))
            {
                // Optionally register only 1 frame out of every n  可选择每n只注册1帧
                _flipFlop = (_flipFlop + 1) % Ignore;
                if (_flipFlop == 0)
                {
                    _video.Add(a.GetCoords());
                }
            }

            // Update the debug window with Sequences information  使用序列信息更新调试窗口
            //dtwTextOutput.Text = _dtw.RetrieveText();
        }
 private void NuiSkeleton2DdataCoordReady(object sender, Skeleton2DdataCoordEventArgs a)
 {
     currentBufferFrame.Text = _video.Count.ToString();
     // We need a sensible number of frames before we start attempting to match gestures against remembered sequences
     if (_video.Count > MinimumFrames && _capturing == false)
     {
         ////Debug.WriteLine("Reading and video.Count=" + video.Count);
         string s = _dtw.Recognize(_video);
         results.Text = "Recognised as: " + s;
         if (!s.Contains("__UNKNOWN"))
         {
             // There was no match so reset the buffer
             _video = new ArrayList();
         }
     }
     // Ensures that we remember only the last x frames
     if (_video.Count > BufferSize)
     {
         // If we are currently capturing and we reach the maximum buffer size then automatically store
         if (_capturing)
         {
             DtwStoreClick(null, null);
         }
         else
         {
             // Remove the first frame in the buffer
             _video.RemoveAt(0);
         }
     }
     // Decide which skeleton frames to capture. Only do so if the frames actually returned a number.
     // For some reason my Kinect/PC setup didn't always return a double in range (i.e. infinity) even when standing completely within the frame.
     // TODO Weird. Need to investigate this
     if (!double.IsNaN(a.GetPoint(0).X))
     {
         // Optionally register only 1 frame out of every n
         _flipFlop = (_flipFlop + 1) % Ignore;
         if (_flipFlop == 0)
         {
             _video.Add(a.GetCoords());
         }
     }
     // Update the debug window with Sequences information
     //dtwTextOutput.Text = _dtw.RetrieveText();
 }
Пример #4
0
        private void NuiSkeleton2DdataCoordReady(object sender, Skeleton2DdataCoordEventArgs a)
        {
            if (_kinectHandler == null || _seqCoords == null || _dtw == null) return;

                if (_seqCoords.Count > MINIMUM_FRAMES && !_isRecording && _isRecognizing)
                {
                    ////Console.Out.WriteLine("No of frames: " + seqCoords.Count);
                    if (_dtw != null)
                    {
                        var g = _dtw.Recognize(_seqCoords, _ctxt);

                        if (_recTimer != null && (g != null || _recTimer.ElapsedMilliseconds > 4000))
                        {
                            _isRecognizing = false;
                            _seqCoords.Clear();

                                if (g != null && (!g.Name.Equals("__UNKNOWN") || _recTimer.ElapsedMilliseconds > 4000))
                                    _kinectHandler.GestureRecognitionCompleted(g.Name);
                        }
                    }
                }

                if (_isRecording)
                {
                    _kinectHandler.RecordingCountdownEvent(_seqCoords.Count);
                }

                if (_seqCoords.Count > BUFFER_SIZE)
                {
                    lock (this) {
                        if (_isRecording && _currentGesture != null)
                        {
                            _isRecording = false;

                            if (_dtw != null) _dtw.AddOrUpdate(_seqCoords, _currentGesture);
                            _seqCoords.Clear();
                            _kinectHandler.GestureRecordCompleted(_currentGesture.Name, _currentGesture.Context);
                            _currentGesture = null;
                        }
                        else
                        {
                            _seqCoords.RemoveAt(0);
                        }
                    }
                }

            if (a == null || Double.IsNaN(a.GetPoint(0).X)) return;
            // Optionally register only 1 frame out of every n
            _flipFlop = (_flipFlop + 1)%IGNORE;
            if (_flipFlop == 0)
            {
                _seqCoords.Add(a.GetCoords());
            }
        }
        private void NuiSkeleton2DdataCoordReady(object sender, Skeleton2DdataCoordEventArgs a)
        {
            currentBufferFrame.Text = _video.Count.ToString();

            if (_video.Count > MinimumFrames && _capturing == false)
            {
                ////Debug.WriteLine("Reading and video.Count=" + video.Count);
                string s = _dtw.Recognize(_video);
                results.Text = "Recognize: " + s;
                if (!s.Contains("__UNKNOWN"))
                {
                    _video = new ArrayList();
                }
            }

            if (_video.Count > BufferSize)
            {
                
                if (_capturing)
                {
                    DtwStoreClick(null, null);
                }
                else
                {
                    _video.RemoveAt(0);
                }
            }

            if (!double.IsNaN(a.GetPoint(0).X))
            {

                _flipFlop = (_flipFlop + 1) % Ignore;
                if (_flipFlop == 0)
                {
                    _video.Add(a.GetCoords());
                }
            }

            //dtwTextOutput.Text = _dtw.RetrieveText();
        }
        /// <summary>
        /// Runs every time our 2D coordinates are ready.
        /// </summary>
        /// <param name="sender">The sender object</param>
        /// <param name="a">Skeleton 2Ddata Coord Event Args</param>
        /// Work Cited: http://kinectdtw.codeplex.com/
        private void NuiSkeleton2DdataCoordReady(object sender, Skeleton2DdataCoordEventArgs a)
        {
            // We need a sensible number of frames before we start attempting to match gestures against remembered sequences
            if (_video.Count > MinimumFrames)
            {
                ////Debug.WriteLine("Reading and video.Count=" + video.Count);
                string s = _dtw.Recognize(_video);
                if (!s.Contains("__UNKNOWN"))
                {
                    // There was no match so reset the buffer
                    _video = new ArrayList();
                }
                if (s.Contains("changeAvatar"))
                {
                    _skeleton.cycleAvatar();
                }
            }

            // Ensures that we remember only the last x frames
            if (_video.Count > BufferSize)
            {
                // Remove the first frame in the buffer
                _video.RemoveAt(0);
            }

            // Decide which skeleton frames to capture. Only do so if the frames actually returned a number.
            // For some reason my Kinect/PC setup didn't always return a double in range (i.e. infinity) even when standing completely within the frame.
            // TODO Weird. Need to investigate this
            if (!double.IsNaN(a.GetPoint(0).X))
            {
                // Optionally register only 1 frame out of every n
                _flipFlop = (_flipFlop + 1) % Ignore;
                if (_flipFlop == 0)
                {
                    _video.Add(a.GetCoords());
                }
            }
        }