Microsoft_Kinect_VisualGestureBuilder_VisualGestureBuilderFrameArrivedEventArgs_Delegate_Handler( RootSystem.IntPtr result, RootSystem.IntPtr pNative) { List <RootSystem.EventHandler <VisualGestureBuilderFrameArrivedEventArgs > > callbackList = null; Microsoft_Kinect_VisualGestureBuilder_VisualGestureBuilderFrameArrivedEventArgs_Delegate_callbacks .TryGetValue(pNative, out callbackList); lock (callbackList) { var objThis = NativeObjectCache.GetObject <VisualGestureBuilderFrameReader>(pNative); var args = new VisualGestureBuilderFrameArrivedEventArgs(result); foreach (var func in callbackList) { EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); } } }
void _gestureFrameReader_FrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { using (VisualGestureBuilderFrame frame = e.FrameReference.AcquireFrame()) { if (frame != null && frame.DiscreteGestureResults != null) { if (AttachedObject == null) return; DiscreteGestureResult result = null; if (frame.DiscreteGestureResults.Count > 0) result = frame.DiscreteGestureResults[_squat]; if (result == null) return; if (result.Detected == true) { var progressResult = frame.ContinuousGestureResults[_squat]; if (AttachedObject != null) { var prog = progressResult.Progress; float scale = 0.5f + prog * 3.0f; AttachedObject.transform.localScale = new Vector3(scale, scale, scale); } } } } }
void gestureFrameReaders_FrameArrived( object sender, VisualGestureBuilderFrameArrivedEventArgs e ) { VisualGestureBuilderFrame gestureFrame = e.FrameReference.AcquireFrame(); if ( gestureFrame==null ) { return; } UpdateGestureFrame( gestureFrame ); gestureFrame.Dispose(); }
private void FrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { var list = new List<KinectGesture>(); using (var frame = e.FrameReference.AcquireFrame()) { if (frame == null) return; list.AddRange(from result in frame.DiscreteGestureResults let gesture = result.Key let gestureResult = result.Value where gestureResult.Detected select new KinectGesture { Name = gesture.Name, TrackingId = TrackingId, IsContinuous = false, Value = gestureResult.Confidence } ); list.AddRange(from result in frame.ContinuousGestureResults let gesture = result.Key let gestureResult = result.Value where gestureResult.Progress > 0 select new KinectGesture { Name = gesture.Name, TrackingId = TrackingId, IsContinuous = true, Value = gestureResult.Progress } ); } FrameReady(this, new KinectItemListEventArgs<KinectGesture>(Manager.SensorId, list)); }
private void gestureFrameReader_FrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { using (var gestureFrame = e.FrameReference.AcquireFrame()) { // ジェスチャーの判定結果がある場合 if (gestureFrame != null && gestureFrame.DiscreteGestureResults != null) { var result = gestureFrame.DiscreteGestureResults[jump]; if (result.Detected) { // ジャンプしている場合、その進捗をプログレスバーに反映 var progressResult = gestureFrame.ContinuousGestureResults[jumpProgress]; ProgressBar1.Value = progressResult.Progress; } else { ProgressBar1.Value = 0.0; } TextBlock1.Text = result.Detected ? "Jump!" : "No Gesture Found."; // ジャンプしているか? TextBlock2.Text = "Confidence: " + result.Confidence.ToString(); // ジャンプの確からしさ } } }
/// <summary> /// Handles gesture detection results arriving from the sensor for the associated body tracking Id /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the discrete gesture results which arrived with the latest frame IReadOnlyDictionary<Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { // we only have one gesture in this source object, but you can get multiple gestures foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.Name.Equals(this.waveGestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { GestureEventArgs args = new GestureEventArgs(); args.Confidence = result.Confidence; args.Name = gesture.Name; // Fire off event to KinectModel if (GestureDetected != null && args != null) { GestureDetected(args); } } } } } } } }
private void gestureFrameReader_FrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { using (var gestureFrame = e.FrameReference.AcquireFrame()) { if (gestureFrame != null && gestureFrame.DiscreteGestureResults != null) { bodySender.addGestures(gestureFrame, gestureFrame.TrackingId, this.discreteGestures, this.continuousGestures); } } }
void vgbFrameReader_FrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the discrete gesture results which arrived with the latest frame IReadOnlyDictionary<Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { int i = 0; // we only have one gesture in this source object, but you can get multiple gestures foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { this.gesturedetected[i] = result.Detected; this.gestureconfidence[i] = result.Confidence; } } i++; } } IReadOnlyDictionary<Gesture, ContinuousGestureResult> continuousResults = frame.ContinuousGestureResults; if (continuousResults != null) { int i = 0; // we only have one gesture in this source object, but you can get multiple gestures foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.GestureType == GestureType.Continuous) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { this.gestureprogress[i] = result.Progress; } } i++; } } } } }
/// <summary> /// Handles gesture detection results arriving from the sensor for the associated body tracking Id /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the discrete gesture results which arrived with the latest frame IReadOnlyDictionary<Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { // we only have one gesture in this source object, but you can get multiple gestures foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.GestureType == GestureType.Discrete) // && gesture.Name.Equals(this.seatedGestureName)) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence); if (result.Confidence > 0.15) { DateTime timestamp = DateTime.MinValue; var timestampExists = this.gestureTimestamps.TryGetValue(gesture.Name, out timestamp); if (lastGestureIdentified != gesture.Name && (DateTime.UtcNow - timestamp).TotalMilliseconds > 1000) { if (this.GestureDetected != null) { this.GestureDetected(this, new GestureEventArgs() { Gesture = gesture.Name }); } Debug.WriteLine("=========== " + gesture.Name + " " + lastGestureIdentified + " / " + timestamp + " ==========="); timestamp = DateTime.UtcNow; if (timestampExists) this.gestureTimestamps[gesture.Name] = timestamp; else this.gestureTimestamps.Add(gesture.Name, timestamp); } } } } } } } } }
private void VgbFrameReader_FrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { float progress = 0; //using (var frame = vgbFrameReader.CalculateAndAcquireLatestFrame()) using (var frame = e.FrameReference.AcquireFrame()) { if (frame != null) { // get all discrete and continuous gesture results that arrived with the latest frame var discreteResults = frame.DiscreteGestureResults; var continuousResults = frame.ContinuousGestureResults; if (discreteResults != null) { foreach (var gesture in vgbFrameSource.Gestures) { DiscreteGestureResult discreteResult = null; ContinuousGestureResult continuousResult = null; if (gesture.GestureType == GestureType.Discrete) { discreteResults.TryGetValue(gesture, out discreteResult); if (discreteResult != null) { continuousResults.TryGetValue(ContinuousGestureData, out continuousResult); if (continuousResult != null) { progress = continuousResult.Progress; if (progress < 0f) { progress = 0.0f; } else if (progress > 1.0) { progress = 1.0f; } } } } //update the analyzer if (continuousResult != null && discreteResult != null) { //if (!StopDetection) _gestureAnalysis.UpdateGestureResult(gesture.Name, discreteResult, progress); //Console.WriteLine("Gesture {0}, confidance {1}, progress", gesture.Name, discreteResult.Confidence, progress); } }// foreach }//if (discrete != null) //else //{ // //_gestureAnalysis.CheckIfRoundSucces(); //} }//if (frame != null) }//using }
/// <summary> /// Handles gesture detection results arriving from the sensor for the associated body tracking Id /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the discrete gesture results which arrived with the latest frame var discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { // we only have one gesture in this source object, but you can get multiple gestures foreach (Gesture gesture in this.vgbFrameSource.Gestures) { // if (gesture.Name.Equals(this.seatedGestureName) && gesture.GestureType == GestureType.Discrete) // { // DiscreteGestureResult result = null; // discreteResults.TryGetValue(gesture, out result); // // if (result != null) // { // if (this.OnGestureDetected != null) // { // //this.OnGestureDetected(this, new GestureEventArgs(true, result.Detected, result.Confidence)); // Debug.Log ("seated"); // } // } // } if (gesture.Name.Equals("stretch") && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { if(this.OnGestureDetected != null && result.Confidence == 1) { // Debug.Log ("lightening fired"); // kinectManager.ActivateSpell(1); if(!stretched){ Debug.Log ("stretch detected"); stretched = true; ScoreEncourageText.UpdateMove(); } } else { stretched = false; } } } /* if (gesture.Name == turnLeft && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { if(this.OnGestureDetected != null && result.Confidence >= .3f) { kinectManager.TurnLeft(result.Confidence); } } } if (gesture.Name == turnRight && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { if(this.OnGestureDetected != null && result.Confidence >= .3f) { kinectManager.TurnLeft(-result.Confidence); } } } if (gesture.Name.Equals(this.meteor) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { if(this.OnGestureDetected != null && result.Confidence == 1) { kinectManager.ActivateSpell(2); } } } if (gesture.Name == walking && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { if(this.OnGestureDetected != null && result.Confidence == 1) { kinectManager.Walk(result.Confidence); } } } */ } } //get the continuous results which arrived with the latest frame var continuousResults = frame.ContinuousGestureResults; if (continuousResults != null) { foreach (Gesture gesture in this.vgbFrameSource.Gestures) { // Debug.Log ("searching for Conti motion"); // if(gesture.Name.Equals (this.notseatedGestureName) && gesture.GestureType == GestureType.Continuous) // { // Debug.Log ("found Conti!"); // ContinuousGestureResult resultCon = null; // continuousResults.TryGetValue(gesture, out resultCon); // //// DiscreteGestureResult resultDis = null; //// discreteResults.TryGetValue(gesture, out resultDis); // // if(resultCon.Progress >= .6f) //&& resultDis != null) // { // if (this.OnGestureDetected != null) // { // kinectManager.ActivateSpell(1); // Debug.Log ("twirled"); // } // } // } // if(gesture.Name.Equals (this.meteor) && gesture.GestureType == GestureType.Continuous) // { // Debug.Log ("meteor!!"); // ContinuousGestureResult resultCon = null; // continuousResults.TryGetValue(gesture, out resultCon); // // if(resultCon.Progress >= .7f) // { // if(this.OnGestureDetected != null) // { // kinectManager.ActivateSpell(2); // Debug.Log ("meteor is down!"); // } // } // } } } } } }
/// Handles gesture detection results arriving from the sensor for the associated body tracking Id private void GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using(VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if(frame != null) { // get the discrete gesture results which arrived with the latest frame IDictionary<Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; IDictionary<Gesture, ContinuousGestureResult> continuousResults = frame.ContinuousGestureResults; if(discreteResults != null) { foreach(Gesture gesture in _Source.Gestures) { if(gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if(result != null) { // Debug.Log("Detected Gesture " + gesture.Name + " with Confidence " + result.Confidence); if(gesture.Name == "Faster" && result.Confidence >= 0.5f && !fasterhappened) { //TODO potenziell Namen vom Script ändern Debug.Log("faster"); gameObject.GetComponentInChildren<CubeScript>().moveForward(); fasterhappened = true; } fasterhappened = false; if(gesture.Name == "Slower" && result.Confidence >= 0.5f && !slowerhappened) { Debug.Log("slower"); gameObject.GetComponentInChildren<CubeScript>().moveBackward(); slowerhappened = true; } slowerhappened = false; } } else if(gesture.GestureType == GestureType.Continuous) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if(result != null) { Debug.Log("Detected Gesture " + gesture.Name + " with Progress " + result.Progress); if(gesture.Name == "LeanForwardBackward" && (result.Progress >= 0.2f || result.Progress <= -0.2f) ) { gameObject.GetComponentInChildren<CubeScript>().moveY(result.Progress); } if(gesture.Name == "LeanLeftRightProgress" // && (result.Progress >= 0.2f || result.Progress <= -0.2f) ) { gameObject.GetComponentInChildren<CubeScript>().moveX(result.Progress); } if(gesture.Name == "DrehungContinouos" // && (result.Progress >= 0.1f) ) { Debug.Log("gesture.Name == DrehungContinouos"); gameObject.GetComponentInChildren<CubeScript>().rotate(result.Progress); } } } } } } } }
/// <summary> /// Handles gesture detection results arriving from the sensor for the associated body tracking Id /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the discrete gesture results which arrived with the latest frame IReadOnlyDictionary<Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { // we only have one gesture in this source object, but you can get multiple gestures foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.Name.Equals(this.gestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values //this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence); MainWindow.GestureRecieved(gestureName, TrackingId, result.Detected, result.Confidence); } } } } } } }
/// <summary> /// Handles gesture detection results arriving from the sensor for the associated body tracking id /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event argument</param> private void GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if(frame != null) { IReadOnlyDictionary<Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; if(discreteResults != null) { foreach(var gesture in gestureFrameSource.Gestures) { if(gestureNameList.Contains(gesture.Name)) { //DiscreteGestureResult result = null; DiscreteGestureResult result; discreteResults.TryGetValue(gesture, out result); if(result != null) { GestureResultView.UpdateGestureResult(gesture.Name,true, result.Detected, result.Confidence); } } } } } } }
/// <summary> /// Handles gesture detection results arriving from the sensor for the associated body tracking Id /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the discrete gesture results which arrived with the latest frame var discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { // we only have one gesture in this source object, but you can get multiple gestures foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.Name.Equals(this.leanLeftGestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { if (this.OnGestureDetected != null) { this.OnGestureDetected(this, new GestureEventArgs(true, result.Detected, result.Confidence, this.leanLeftGestureName)); } } } if (gesture.Name.Equals(this.leanRightGestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { if (this.OnGestureDetected != null) { this.OnGestureDetected(this, new GestureEventArgs(true, result.Detected, result.Confidence, this.leanRightGestureName)); } } } } } } } }
/// <summary> /// Handles gesture detection results arriving from the sensor for the associated body tracking Id /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the discrete gesture results which arrived with the latest frame IReadOnlyDictionary<Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; IReadOnlyDictionary<Gesture, ContinuousGestureResult> contResults = frame.ContinuousGestureResults; if (discreteResults != null) { // we only have one gesture in this source object, but you can get multiple gestures foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.Name.Equals(this.sw1Name) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values if (result.Confidence > 0.25) { sw1Done = true; //Console.Write("\nsw1Name RESULT: " + result.Detected + "|" + result.Confidence); } this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence); } } if (gesture.Name.Equals(this.sw2Name) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values if (result.Confidence > 0.23 & sw1Done) { sw2Done = true; //Console.Write("\nsw2Name RESULT: " + result.Detected + "|" + result.Confidence); } this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence); } } //-----------------------------------------SW1 & SW2 ------------------------------------------------------------------------ //--------------------------------------------------------------------------------------------------------------------------- if (gesture.Name.Equals(this.ct1Name) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values if (result.Confidence >= 0.95) { ct1Done = true; //Console.Write("\nct1Name RESULT: " + result.Detected + " | " + result.Confidence + " | " + frameCount); } this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence); } } if (gesture.Name.Equals(this.ct2Name) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values if (result.Confidence >= 0.95 && ct1Done) { ct2Done = true; //Console.Write("\nct2Name RESULT: " + result.Detected + "|" + result.Confidence + " | " + frameCount); } this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence); } } // } } frameCount++; } } }
/// <summary> /// Handles gesture detection results arriving from the sensor for the associated body tracking Id /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the discrete gesture results which arrived with the latest frame IReadOnlyDictionary<Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; Gesture detectedGesture = null; DiscreteGestureResult detectedResult = null; if (discreteResults != null) { // Publish the discrete results PublishDiscreteGestureResult(discreteResults); // we only have one gesture in this source object, but you can get multiple gestures foreach (Gesture gesture in _vgbFrameSource.Gestures) { //System.Diagnostics.Debug.WriteLine(gesture.Name); if (gesture.GestureType == GestureType.Discrete && _gestures.Contains(gesture.Name)) //if (gesture.Name.Equals(this.seatedGestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result; discreteResults.TryGetValue(gesture, out result); //if (result != null && result.Detected) if (result != null) { if (result.Detected) { detectedGesture = gesture; detectedResult = result; break; } // update the GestureResultView object with new gesture result values //this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, gesture.Name); } } } } if (detectedGesture != null) { GestureResultView.UpdateGestureResult(true, detectedResult.Detected, detectedResult.Confidence, detectedGesture.Name); } else { GestureResultView.UpdateGestureResult(true, false, 0.0f, string.Empty); } } } }
/// <summary> /// Handles gesture detection results arriving from the sensor for the associated body tracking Id /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the discrete gesture results which arrived with the latest frame Dictionary<Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { // we only have one gesture in this source object, but you can get multiple gestures foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.Name.Equals(this.shootingGestureName)) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { shotFired = result.Detected && result.Confidence > shootingCertaintyThreshold; /* if (result.Detected && result.Confidence > shootingCertaintyThreshold) { KinectManager.shotFired(TrackingId); } */ } // update the GestureResultView object with new gesture result values } } } } } }
private void OnFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { using (var frame = e.FrameReference.AcquireFrame()) { if (frame == null) { return; } if (frame.DiscreteGestureResults == null) { return; } foreach (var gestureKey in frame.DiscreteGestureResults.Keys.Where(gestureKey => frame.DiscreteGestureResults[gestureKey].Detected)) { switch (gestureKey.Name) { case "TakeControl": if (TakeControl != null) TakeControl(this, EventArgs.Empty); break; case "Next": if (Next != null) Next(this, EventArgs.Empty); break; case "Previous": if (Previous != null) Previous(this, EventArgs.Empty); break; case "End": if (End != null) End(this, EventArgs.Empty); break; } } } }
/// <summary> /// 处理从kinect设备发送来的手势检测结果,该结果是对应追踪已标识身体的结果。 /// </summary> /// <param name="sender">发送事件的对象</param> /// <param name="e">事件数据集</param> private void GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the discrete gesture results which arrived with the latest frame IDictionary<Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { foreach (Gesture gesture in m_VGBSource.Gestures) { if (gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; // if (discreteResults.TryGetValue(gesture, out result)) { // Fire Event if (this.OnGesture != null) { this.OnGesture(this, new GestureEventArgs(gesture.Name, true, result.Detected, result.Confidence)); } } } } } } } }
/// <summary> /// Handles gesture detection results arriving from the sensor for the associated body tracking Id /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the discrete gesture results which arrived with the latest frame IReadOnlyDictionary<Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.Name.Equals(this.waveGestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values if (result.Detected) { if (!isWaveDetectedStatus ) { waveCount++; //Console.WriteLine("aaa"); isWaveDetectedStatus = true; if (this.bodiesSelectStatus[this.GestureResultView.BodyIndex]==1) { //Process the activity only while the detected body raise his/her hand recently Console.WriteLine("["+this.GestureResultView.BodyIndex +"]"+ " Left " + waveCount); this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, " Left"); ctrlAndPageUpClick(); //Pause detecting to avoid conflict Thread.Sleep(sleepingTime); } } } else { if (isWaveDetectedStatus) { isWaveDetectedStatus = false; } } } } else if (gesture.Name.Equals(this.waveRightGestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult rightResult = null; discreteResults.TryGetValue(gesture, out rightResult); if (rightResult != null) { // update the GestureResultView object with new gesture result values if (rightResult.Detected) { if (!isWaveRightDetectedStatus) { waveRightCount++; isWaveRightDetectedStatus = true; if (this.bodiesSelectStatus[this.GestureResultView.BodyIndex] == 1) { //Process the activity only while the detected body raise his/her hand recently Console.WriteLine("[" + this.GestureResultView.BodyIndex + "]" +" Right " + waveRightCount); this.GestureResultView.UpdateGestureResult(true, rightResult.Detected, rightResult.Confidence, " Right"); ctrlAndPageDownClick(); //Pause detecting to avoid conflict Thread.Sleep(sleepingTime); } } } else { if (isWaveRightDetectedStatus) { isWaveRightDetectedStatus = false; } } } } else if (gesture.Name.Equals(this.raiseRightHandGestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult raiseRightHandResult = null; discreteResults.TryGetValue(gesture, out raiseRightHandResult); if (raiseRightHandResult != null) { if (raiseRightHandResult.Detected) { if (this.bodiesSelectStatus[this.bodyIndex] == 0) { Console.WriteLine("[" + this.GestureResultView.BodyIndex + "]" + " body is detected"); this.GestureResultView.UpdateGestureResult(true, raiseRightHandResult.Detected, raiseRightHandResult.Confidence, "detected "); } this.bodyIndex = this.GestureResultView.BodyIndex; for (int i = 0; i < bodiesSelectStatus.Length; i++) { this.bodiesSelectStatus[i] = 0; } this.bodiesSelectStatus[this.GestureResultView.BodyIndex] = 1; } } } else if (gesture.Name.Equals(this.raiseLeftHandGestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult raiseLeftHandResult = null; discreteResults.TryGetValue(gesture, out raiseLeftHandResult); if (raiseLeftHandResult != null) { if (raiseLeftHandResult.Detected) { //this.bodyIndex = this.GestureResultView.BodyIndex; //Release all detectation if (this.bodiesSelectStatus[this.bodyIndex] == 1) { Console.WriteLine("[" + this.GestureResultView.BodyIndex + "]" + " body is released"); this.GestureResultView.UpdateGestureResult(true, raiseLeftHandResult.Detected, raiseLeftHandResult.Confidence, " released "); } for (int i = 0; i < bodiesSelectStatus.Length; i++) { this.bodiesSelectStatus[i] = 0; } //this.bodiesSelectStatus[this.GestureResultView.BodyIndex] = 1; } } } } } } } }
/// <summary> /// Handles gesture detection results arriving from the sensor for the associated body tracking Id /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { this.num_gestures_detected = 0; VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the discrete gesture results which arrived with the latest frame IReadOnlyDictionary<Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { // we only have one gesture in this source object, but you can get multiple gestures foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.num_frames, this.num_frames_touchingface, this.num_frames_leaning); this.num_frames++; if (result.Detected && result.Confidence > .3) { this.num_gestures_detected++; if (gesture.Name == "TouchingFace") { this.num_frames_touchingface++; } if (gesture.Name == "Leaning") { this.num_frames_leaning++; } } } } } } } } // make call to change background with num_detected as a parameter }
/// <summary> /// Handles gesture detection results arriving from the sensor for the associated body tracking Id /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { if (!isCoolingDown) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the discrete gesture results which arrived with the latest frame IReadOnlyDictionary<Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { // we only have one gesture in this source object, but you can get multiple gestures foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (this.gestureNames.Contains(gesture.Name) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null && result.Detected) { if (result.Confidence >= confidenceThreshold) { GesturePerformed(this, new GestureEventArgs(gesture.Name, result.Confidence)); isCoolingDown = true; timer.Start(); } } } } } } } } }
/// Handles gesture detection results arriving from the sensor for the associated body tracking Id private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the discrete gesture results which arrived with the latest frame IReadOnlyDictionary<Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.Name.Equals(this.leftGestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values this.GestureResultView.UpdateGestureResult1(true, result.Detected, result.Confidence); } } if (gesture.Name.Equals(this.rightGestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values this.GestureResultView.UpdateGestureResult2(true, result.Detected, result.Confidence); } } if (gesture.Name.Equals(this.upGestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values this.GestureResultView.UpdateGestureResult3(true, result.Detected, result.Confidence); } } if (gesture.Name.Equals(this.downGestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values this.GestureResultView.UpdateGestureResult4(true, result.Detected, result.Confidence); } } if (gesture.Name.Equals(this.voiceGestureName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values this.GestureResultView.UpdateGestureResult5(true, result.Detected, result.Confidence); } } } } } } }