/// <summary> /// Listener of Kinect gesture frames. /// </summary> /// <param name="sender">The sender object.</param> /// <param name="e">The kinect gesture frame.</param> public void Gesture_FrameArrived(object sender, KinectGestureFrameArrivedArgs e) { CheckPerson.Instance.CheckIfExistsPerson(e.TrackingId); if (e.Time.HasValue) { //process discrete gestures if (!ReferenceEquals(null, e?.Frame?.DiscreteGestureResults)) { foreach (var discreteGesture in e.Frame.DiscreteGestureResults) { if (discreteGesture.Value.Detected) { var tuple = new Tuple <Person, string>(CheckPerson.Instance.PersonsId[e.TrackingId], discreteGesture.Key.Name); if (!_discreteGestures.Exists(d => d.Equals(tuple))) { _discreteGestures.Add(tuple); } //check in the variable if has processed, if not, check in the database and then add it to variable if (!_processedDiscreteGestureNames.Exists(pd => pd.Equals(discreteGesture.Key.Name))) { _dataAccessFacade.GetSubModalAccess().AddIfNotExists("Discrete Posture", discreteGesture.Key.Name, "Autogenerated", null); _processedDiscreteGestureNames.Add(discreteGesture.Key.Name); } if (discreteGesture.Value.Detected) { _dataAccessFacade.GetEventAccess().Add(CheckPerson.Instance.PersonsId[e.TrackingId], "Discrete Posture", discreteGesture.Key.Name, e.Time.Value, discreteGesture.Value.Confidence, 1); } else { _dataAccessFacade.GetEventAccess().Add(CheckPerson.Instance.PersonsId[e.TrackingId], "Discrete Posture", discreteGesture.Key.Name, e.Time.Value, discreteGesture.Value.Confidence, -1); } } } } //process continuous gestures if (!ReferenceEquals(null, e?.Frame?.ContinuousGestureResults)) { foreach (var continuousGesture in e.Frame.ContinuousGestureResults) { //check in the variable if has processed, if not, check in the database and then add it to variable if (!_processedDiscreteGestureNames.Exists(pd => pd.Equals(continuousGesture.Key.Name))) { _dataAccessFacade.GetSubModalAccess().AddIfNotExists("Continuous Posture", continuousGesture.Key.Name, "Autogenerated", null); _processedDiscreteGestureNames.Add(continuousGesture.Key.Name); } _dataAccessFacade.GetEventAccess().Add(CheckPerson.Instance.PersonsId[e.TrackingId], "Continuous Posture", continuousGesture.Key.Name, e.Time.Value, continuousGesture.Value.Progress, -1); } } } }
private void VgbFrameReader_FrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { var kFrame = e.FrameReference.AcquireFrame(); if (!ReferenceEquals(null, kFrame)) { var frame = new KinectGestureFrameArrivedArgs() { Time = _dataAccessFacade.GetSceneInUseAccess().GetLocation(), TrackingId = TrackingId, Frame = kFrame }; OnKinectGestureFrameArrived(frame); } }
private void OnKinectGestureFrameArrived(KinectGestureFrameArrivedArgs e) { KinectGestureFrameArrived?.Invoke(this, e); }