/// <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 NuiSkeleton3DdataCoordReady(object sender, Skeleton3DdataCoordEventArgs 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); if (s.Contains("@Right hand swipe left")) { WindowState = WindowState.Maximized; } else if (s.Contains("@Left hand swipe right")) { WindowState = WindowState.Normal; } else if (s.Contains("@Right hand pull down")) { WindowState = WindowState.Minimized; } else if (s.Contains("@Right hand push up")) { WindowState = WindowState.Normal; } 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(); }