/// <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(); }
/// <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(); }