private void Reader_GestureFrameArrived_Continuous(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { // get the continuous gesture results which arrived with the latest frame var continuousResults = frame.ContinuousGestureResults; if (continuousResults != 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.Continuous) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { if (this.OnGestureDetected != null) { this.OnGestureDetected(this, new GestureEventArgs(true, result.Progress <= 0.01, result.Progress)); } } } } } } } }
public void addGestures(VisualGestureBuilderFrame gestureFrame, ulong id, List <Gesture> discrete, List <Gesture> continuous) { DateTime reference = new DateTime(2001, 01, 01, 0, 0, 0, DateTimeKind.Utc); TimeSpan duration = new TimeSpan(DateTime.UtcNow.Ticks - reference.Ticks); ulong minutesCount = Convert.ToUInt64(duration.TotalMinutes); OscTimeTag timestamp = new OscTimeTag(minutesCount); List <OscMessage> messages = new List <OscMessage>(); foreach (Gesture gest in discrete) { DiscreteGestureResult result = gestureFrame.DiscreteGestureResults[gest]; messages.Add(messageBuilder.BuildGestureMessage(id.ToString(), gest.Name, result.Detected, result.Confidence)); } foreach (Gesture gest in continuous) { ContinuousGestureResult result = gestureFrame.ContinuousGestureResults[gest]; messages.Add(messageBuilder.BuildGestureMessage(id.ToString(), gest.Name, result.Progress)); } OscBundle target = new OscBundle(timestamp, messages.ToArray()); this.Broadcast(target); }
private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { IReadOnlyDictionary <Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; IReadOnlyDictionary <Gesture, ContinuousGestureResult> continuousResults = frame.ContinuousGestureResults; if (discreteResults != null) { DiscreteGestureResult SwipeFromLeftResult = null; DiscreteGestureResult SwipeFromRightResult = null; DiscreteGestureResult ZoomOutResult = null; discreteResults.TryGetValue(ZoomOut, out ZoomOutResult); discreteResults.TryGetValue(RightToLeft, out SwipeFromRightResult); discreteResults.TryGetValue(LeftToRight, out SwipeFromLeftResult); if (EnableSwipe && SwipeFromRightResult != null && SwipeFromRightResult.Detected && SwipeFromRightResult.Confidence > 0.35) { Trace.WriteLine("Swipe from right"); OnSwipe(GestureType.RightToLeft); EnableSwipe = false; ResetSwipe(gestureResetTime); } if (EnableSwipe && SwipeFromLeftResult != null && SwipeFromLeftResult.Detected && SwipeFromLeftResult.Confidence > 0.35) { Trace.WriteLine("swipe from left"); OnSwipe(GestureType.LeftToRight); EnableSwipe = false; ResetSwipe(gestureResetTime); } if (EnableZoom && ZoomOutResult != null && ZoomOutResult.Detected && ZoomOutResult.Confidence > 0.5) { OnZoomOut(); } } if (continuousResults != null) { ContinuousGestureResult ClapResult = null; continuousResults.TryGetValue(clapGesture, out ClapResult); if (EnableClap && ClapResult != null) { float clapProg = ClapResult.Progress; if (clapProg > 1.85 && clapProg < 3) { Trace.WriteLine("Clap detected"); EnableClap = false; ResetClap(gestureResetTime); } } } } } }
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++; } } } } }
private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; lock (GestureResults) { using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { IReadOnlyDictionary <Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { GestureResult gr = GestureResults.FirstOrDefault(n => n.Name == gesture.Name); gr.UpdateGestureResult(gesture.Name, true, result.Detected, result.Confidence); } } } } IReadOnlyDictionary <Gesture, ContinuousGestureResult> continuousResults = frame.ContinuousGestureResults; if (continuousResults != null) { foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.GestureType == GestureType.Continuous) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { GestureResult gr = GestureResults.FirstOrDefault(n => n.Name == gesture.Name); gr.UpdateGestureResult(gesture.Name, true, true, result.Progress); } } } } } } } }
/// <summary> /// Actualiza la ultima lectura del sensor de gesturas /// </summary> public void UpdateGestureData() { // Obtiene el respectivo frame a analizar using (var frame = this.vgbFrameReader.CalculateAndAcquireLatestFrame()) { // Verifica si el frame existe if (frame != null) { // Obtiene los resultados del frame de valores coninuo var continuousResults = frame.ContinuousGestureResults; // Obtiene los resulados del proceso float progress = this.GestureResultView.Progress; // Recorre todas las gestura analizar foreach (var gesture in this.vgbFrameSource.Gestures) { // Verifica que tenga el paquete resultado tenga valiables continuas if (continuousResults != null) { // Verifica los atributos a analizar if (gesture.GestureType == GestureType.Continuous) { // Obtengo los valores continuos ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); // Verifica si tienes resultados if (result != null) { progress = result.Progress; } } } // Obtiene resultado dentro del parametro continuo if (progress < MINDETECTOR) { progress = MINDETECTOR; } else if (progress > MAXDETECTOR) { progress = MAXDETECTOR; } // Actualiza los resultados this.GestureResultView.UpdateGestureResult(true, 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; IReadOnlyDictionary <Gesture, ContinuousGestureResult> continuousResults = frame.ContinuousGestureResults; if (continuousResults != 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.Continuous) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values // this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence); var progress = result.Progress; if (progress > 1.48 && progress < 3) { //we're clapping but not finished this.GestureResultView.UpdateGestureResult(true, true, 1.0f); } else { this.GestureResultView.UpdateGestureResult(true, false, 1.0f); } } } } } } } }
/// <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()) { bool isGestureDetected = false; bool iscrouched = false; bool isdabbing = false; bool isheying = false; bool isholding = false; bool isreloading = false; float level = 0; if (frame != null) { // get the discrete gesture results which arrived with the latest frame IReadOnlyDictionary <Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; IReadOnlyDictionary <Gesture, ContinuousGestureResult> continuousResults = frame.ContinuousGestureResults; if (discreteResults != null) { } if (continuousResults != null) { foreach (Gesture gesture in vgbFrameSource.Gestures) { if (gesture.Name.Equals(this.crouch_gesture) || gesture.Name.Equals(this.dab_gesture) || gesture.Name.Equals(this.hey_gesture) || gesture.Name.Equals(this.hold_gesture) || gesture.Name.Equals(this.reload_gesture)) { { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { level = result.Progress; if (level >= 0.8) { hysterisis++; if (hysterisis != 20) { return; } hysterisis = 0; ((MainWindow)System.Windows.Application.Current.MainWindow).overlay_crouch.Opacity = 0.0; ((MainWindow)System.Windows.Application.Current.MainWindow).overlay_dab.Opacity = 0.0; ((MainWindow)System.Windows.Application.Current.MainWindow).overlay_hey.Opacity = 0.0; ((MainWindow)System.Windows.Application.Current.MainWindow).overlay_hold.Opacity = 0.0; ((MainWindow)System.Windows.Application.Current.MainWindow).overlay_reload.Opacity = 0.0; ((MainWindow)System.Windows.Application.Current.MainWindow).overlay_normal.Opacity = 0.0; if (gesture.Name.Equals(crouch_gesture)) { sre_GestureRecognized(level, "CROUCH"); Console.WriteLine(" CROUCH "); isGestureDetected = true; iscrouched = true; isdabbing = false; isheying = false; isholding = false; isreloading = false; // Never do this, use MVVM, only used this because there's no time left ((MainWindow)System.Windows.Application.Current.MainWindow).current_gesture.Text = "Crouch"; ((MainWindow)System.Windows.Application.Current.MainWindow).overlay_crouch.Opacity = 0.5; } else if (gesture.Name.Equals(dab_gesture)) { sre_GestureRecognized(level, "DAB"); Console.WriteLine(" DAB "); isGestureDetected = true; iscrouched = false; isdabbing = true; isheying = false; isholding = false; isreloading = false; ((MainWindow)System.Windows.Application.Current.MainWindow).current_gesture.Text = "Dab"; ((MainWindow)System.Windows.Application.Current.MainWindow).overlay_dab.Opacity = 0.5; } else if (gesture.Name.Equals(hey_gesture)) { sre_GestureRecognized(level, "HEY"); Console.WriteLine(" HEY "); isGestureDetected = true; iscrouched = false; isdabbing = true; isheying = false; isholding = false; isreloading = false; ((MainWindow)System.Windows.Application.Current.MainWindow).current_gesture.Text = "Hey"; ((MainWindow)System.Windows.Application.Current.MainWindow).overlay_hey.Opacity = 0.5; } else if (gesture.Name.Equals(hold_gesture)) { sre_GestureRecognized(level, "HOLD"); Console.WriteLine(" HOLD "); isGestureDetected = true; iscrouched = false; isdabbing = true; isheying = false; isholding = false; isreloading = false; ((MainWindow)System.Windows.Application.Current.MainWindow).current_gesture.Text = "Hold"; ((MainWindow)System.Windows.Application.Current.MainWindow).overlay_hold.Opacity = 0.5; } else if (gesture.Name.Equals(reload_gesture)) { sre_GestureRecognized(level, "RELOAD"); Console.WriteLine(" RELOAD "); isGestureDetected = true; iscrouched = false; isdabbing = true; isheying = false; isholding = false; isreloading = false; ((MainWindow)System.Windows.Application.Current.MainWindow).current_gesture.Text = "Reload"; ((MainWindow)System.Windows.Application.Current.MainWindow).overlay_reload.Opacity = 0.5; } } } } } } GestureResultView.UpdateGestureResult(true, isGestureDetected, iscrouched, isdabbing, isheying, isholding, isreloading, level); } } } }
/// <summary> /// Retrieves the latest gesture detection results from the sensor /// </summary> public void UpdateGestureData() { // VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (var frame = this.vgbFrameReader.CalculateAndAcquireLatestFrame()) { if (frame != null) { // get all discrete and continuous gesture results which arrived with the latest frame IReadOnlyDictionary <Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; IReadOnlyDictionary <Gesture, ContinuousGestureResult> continuousResults = frame.ContinuousGestureResults; if (discreteResults != null) { bool detSeated = this.GestureResultView.DetectedSeated; bool detDrinking = this.GestureResultView.DetectedDrinking; float confSeated = this.GestureResultView.ConfidenceSeated; float confDrinking = this.GestureResultView.ConfidenceDrinking; float drinkingProgress = this.GestureResultView.DrinkingProgress; // 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) { if (gesture.Name.Equals(this.seatedGestureName)) { detSeated = result.Detected; confSeated = result.Confidence; } else if (gesture.Name.Equals(this.drinkingGestureName)) { detDrinking = result.Detected; confDrinking = result.Confidence; } } } if (continuousResults != null) { if (gesture.Name.Equals(this.drinkingProgressGestureName) && gesture.GestureType == GestureType.Continuous) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { drinkingProgress = result.Progress; } } } } // clamp the progress value between 0 and 1 if (drinkingProgress < 0) { drinkingProgress = 0; } else if (drinkingProgress > 1) { drinkingProgress = 1; } // update the GestureResultView object with new gesture result values this.GestureResultView.UpdateGestureResult(true, detSeated, detDrinking, confSeated, confDrinking, drinkingProgress); } } } }
/// <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) { main.SetState("active"); // get the discrete gesture results which arrived with the latest frame IReadOnlyDictionary <Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; var continuousResults = 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 (continuousResults != null) { if (gesture.GestureType == GestureType.Continuous) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values if (result.Progress > 0) { this.GestureResultView.UpdateGestureResult(true, true, result.Progress, gesture.Name); } } } } if (gesture.GestureType == GestureType.Discrete) { //Console.WriteLine(gesture.Name); DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { // update the GestureResultView object with new gesture result values if (result.Confidence > 0.2) { this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, gesture.Name); } } } } } } else { main.SetState("deactive"); } } }
public void getResults(DiscreteGestureResult passedWorkoutDiscrete, ContinuousGestureResult passedWorkoutContinuous, string passedGestureName) { this.workoutDiscrete = passedWorkoutDiscrete; this.workoutContinuous = passedWorkoutContinuous; this.gestureName = passedGestureName; }
private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { if (coms.IsTtsSpeaking()) { return; } if (this.gestureWasDetected) { this.fpsCounter++; if (fpsCounter == fpsDelay) { this.fpsCounter = 0; this.gestureWasDetected = false; MainWindow.main.ChangeDetectedGesture = "No gestures detected"; } return; } VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { IReadOnlyDictionary <Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; IReadOnlyDictionary <Gesture, ContinuousGestureResult> continousResults = frame.ContinuousGestureResults; if (discreteResults != null) { string toSend = null; double toSendConfidence = -1; foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { if (result.Confidence > .10) { Console.WriteLine(gesture.Name); Console.WriteLine(result.Confidence); } Tuple <string, double> t = ProcessDiscreteGesture(result, gesture.Name); double confidence = t.Item2; if (confidence > toSendConfidence) { toSend = t.Item1; toSendConfidence = t.Item2; } } } if (continousResults != null) { if (gesture.GestureType == GestureType.Continuous && gesture.Name.Equals(deleteGestureName)) { ContinuousGestureResult result = null; continousResults.TryGetValue(gesture, out result); if (result != null) { var progress = result.Progress; if (progress > .80 && progress > toSendConfidence) { toSend = deleteGestureName; toSendConfidence = progress; } } } } } if (toSend != null) { SendDetectedGesture(toSend, toSendConfidence); this.gestureWasDetected = true; Console.WriteLine("Detected: " + toSend + " " + toSendConfidence); coms.KeepServerAlive(); } } } } }
private bool UpdateVisualGestures(long userId) { if (vgbFrameSource == null || vgbFrameReader == null) { return(false); } bool wasPaused = vgbFrameReader.IsPaused; vgbFrameSource.TrackingId = (ulong)userId; vgbFrameReader.IsPaused = (userId == 0); if (vgbFrameReader.IsPaused) { if (!wasPaused) { // clear the gesture states foreach (Gesture gesture in vgbFrameSource.Gestures) { if (gestureData.ContainsKey(gesture.Name)) { VisualGestureData data = gestureData[gesture.Name]; data.userId = 0; data.isComplete = false; //data.isResetting = false; data.isProcessed = false; data.confidence = 0f; data.progress = 0f; data.timestamp = Time.realtimeSinceStartup; gestureData[gesture.Name] = data; } } } return(false); } VisualGestureBuilderFrame frame = vgbFrameReader.CalculateAndAcquireLatestFrame(); if (frame != null) { Dictionary <Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; Dictionary <Gesture, ContinuousGestureResult> continuousResults = frame.ContinuousGestureResults; if (discreteResults != null) { foreach (Gesture gesture in discreteResults.Keys) { if (gesture.GestureType == GestureType.Discrete && gestureData.ContainsKey(gesture.Name)) { DiscreteGestureResult result = discreteResults[gesture]; VisualGestureData data = gestureData[gesture.Name]; data.userId = vgbFrameSource.IsTrackingIdValid ? (long)vgbFrameSource.TrackingId : 0; data.isComplete = result.Detected; data.confidence = result.Confidence; data.timestamp = Time.realtimeSinceStartup; //Debug.Log(string.Format ("{0} - {1}, confidence: {2:F0}%", data.gestureName, data.isComplete ? "Yes" : "No", data.confidence * 100f)); if (data.isProcessed && !data.isComplete) { //data.isResetting = false; data.isProcessed = false; } gestureData[gesture.Name] = data; } } } if (continuousResults != null) { foreach (Gesture gesture in continuousResults.Keys) { if (gesture.GestureType == GestureType.Continuous && gestureData.ContainsKey(gesture.Name)) { ContinuousGestureResult result = continuousResults[gesture]; VisualGestureData data = gestureData[gesture.Name]; data.userId = vgbFrameSource.IsTrackingIdValid ? (long)vgbFrameSource.TrackingId : 0; float prevProgress = data.progress; data.progress = result.Progress; data.timestamp = Time.realtimeSinceStartup; if (data.isProcessed && data.progress >= minConfidence && data.progress != prevProgress) { //data.isResetting = false; data.isProcessed = false; } gestureData[gesture.Name] = data; } } } frame.Dispose(); frame = null; } return(true); }
/// <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; var continuousResults = frame.ContinuousGestureResults; if (discreteResults != null) { float steerProgress = this.GestureResultView.SteerProgress; bool detected = false; float confidence = 0.0f; bool right = false; bool left = false; bool close = false; foreach (Gesture gesture in this.vgbFrameSource.Gestures) { // we only have one gesture in this source object, but you can get multiple gestures if (gesture.Name.Equals(this.SlideRight) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { detected = result.Detected; confidence = result.Confidence; right = true; left = false; close = false; } } if (gesture.Name.Equals(this.SlideLeft) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { detected = result.Detected; confidence = result.Confidence; left = true; right = false; close = false; } } if (gesture.Name.Equals(this.close1) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { detected = result.Detected; confidence = result.Confidence; right = false; left = false; close = true; } } if (continuousResults != null) { if (gesture.Name.Equals(this.SlideRightProgress) && gesture.GestureType == GestureType.Continuous) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { steerProgress = result.Progress; right = true; left = false; close = false; } } if (gesture.Name.Equals(this.close1Progress) && gesture.GestureType == GestureType.Continuous) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { steerProgress = result.Progress; right = false; left = false; close = true; } } if (gesture.Name.Equals(this.SlideLeftProgress) && gesture.GestureType == GestureType.Continuous) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { steerProgress = result.Progress; left = true; right = false; close = false; } } } // update the GestureResultView object with new gesture result values this.GestureResultView.UpdateGestureResult(true, detected, confidence, steerProgress, right, left, close); } } } } }
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 <GestureContinuous, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; IDictionary <GestureContinuous, ContinuousGestureResult> continuosResults = frame.ContinuousGestureResults; // we only have one gesture in this source object, but you can get multiple gestures //List<gesturesContinuous> gestures = new List<gesturesContinuous>(); //currentGestures = vgbFrameSource.Gestures; //currentGestures.Clear(); List <GestureContinuous> gesturesPrueba = new List <GestureContinuous>(); resultRel = 0; foreach (var gesture in this.vgbFrameSource.Gestures) { if (continuosResults != null) { if (gesture.GestureType == GestureType.Continuous) { ContinuousGestureResult result = null; continuosResults.TryGetValue(gesture, out result); if (result != null) { if (result.Progress > resultRel) { resultRel = result.Progress; maxContinuosGesture = new KinectCommandConfigMenu.gesturesContinuous(gesture.Name, resultRel); } foreach (string n in KinectCommandConfigMenu.gestureNames) { if (n == gesture.Name) { int index = Array.IndexOf(KinectCommandConfigMenu.gestureNames, n); switch (index) { case 0: Debug.Log("Hand up progress " + result.Progress); if (result.Progress <= KinectCommandConfigMenu.gesture1UntriggerLevel && !KinectCommandConfigMenu.gestureActive[index]) { KinectCommandConfigMenu.gestureActive[index] = true; } break; case 1: Debug.Log("Hand Down progress " + result.Progress); if (result.Progress <= KinectCommandConfigMenu.gesture2UntriggerLevel && !KinectCommandConfigMenu.gestureActive[index]) { KinectCommandConfigMenu.gestureActive[index] = true; } break; case 2: Debug.Log("Hand Right progress " + result.Progress); if (result.Progress <= KinectCommandConfigMenu.gesture3UntriggerLevel && !KinectCommandConfigMenu.gestureActive[index]) { KinectCommandConfigMenu.gestureActive[index] = true; } break; case 3: Debug.Log("Hand Left progress " + result.Progress); if (result.Progress <= KinectCommandConfigMenu.gesture4UntriggerLevel && !KinectCommandConfigMenu.gestureActive[index]) { KinectCommandConfigMenu.gestureActive[index] = true; } break; case 4: //Debug.Log("Hand Left progress " + result.Progress); if (result.Progress <= KinectCommandConfigMenu.gesture5UntriggerLevel && !KinectCommandConfigMenu.gestureActive[index]) { KinectCommandConfigMenu.gestureActive[index] = true; } break; case 5: if (result.Progress <= KinectCommandConfigMenu.gesture6UntriggerLevel && !KinectCommandConfigMenu.gestureActive[index]) { KinectCommandConfigMenu.gestureActive[index] = true; } break; case 6: if (result.Progress <= KinectCommandConfigMenu.gesture7UntriggerLevel && !KinectCommandConfigMenu.gestureActive[index]) { KinectCommandConfigMenu.gestureActive[index] = true; } break; } } } } } } } Debug.Log("========================max gesture kinect manager " + maxContinuosGesture.name + " trigger " + maxContinuosGesture.result); KinectCommandConfigMenu.SetCurrentGesture(maxContinuosGesture); } } }
/// <summary> /// Retrieves the latest gesture detection results from the sensor /// </summary> public void UpdateGestureData() { using (var frame = this.vgbFrameReader.CalculateAndAcquireLatestFrame()) { if (frame != null) { // gets all discrete and continuous gesture results that arrived with the latest frame var discreteResults = frame.DiscreteGestureResults; var continuousResults = frame.ContinuousGestureResults; if (discreteResults != null) { bool scrollUp = this.GestureResultView.GoUp; bool scrollDown = this.GestureResultView.GoDown; bool scrollRight = this.GestureResultView.GoRight; bool scrollLeft = this.GestureResultView.GoLeft; float scrollProgress = this.GestureResultView.ScrollProgress; float scrollSideProgress = this.GestureResultView.ScrollSideProgress; bool zoomIn = this.GestureResultView.GoClose; bool zoomOut = this.GestureResultView.GoFar; float zoomProgress = this.GestureResultView.ZoomProgress; bool upButton = this.GestureResultView.UpButton; bool downButton = this.GestureResultView.DownButton; bool middleButton = this.GestureResultView.MiddleButton; bool startApp = this.GestureResultView.StartApp; foreach (var gesture in this.vgbFrameSource.Gestures) { if (gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { if (gesture.Name.Equals(this.scrollUpGestureName)) { scrollUp = result.Detected; if (scrollUp = result.Detected) { OscMessage OSCmessageScrollUp = new OscMessage(myDetector, "/ScrollUp", 1.0f); OSCmessageScrollUp.Send(myDetector); } } else if (gesture.Name.Equals(this.scrollDownGestureName)) { scrollDown = result.Detected; if (scrollDown = result.Detected) { OscMessage OSCmessageScrollDown = new OscMessage(myDetector, "/ScrollDown", 1.0f); OSCmessageScrollDown.Send(myDetector); } } else if (gesture.Name.Equals(this.scrollRightGestureName)) { scrollRight = result.Detected; if (scrollRight = result.Detected) { OscMessage OSCmessageScrollRight = new OscMessage(myDetector, "/ScrollRight", 1.0f); OSCmessageScrollRight.Send(myDetector); } } else if (gesture.Name.Equals(this.scrollLeftGestureName)) { scrollLeft = result.Detected; if (scrollLeft = result.Detected) { OscMessage OSCmessageScrollLeft = new OscMessage(myDetector, "/ScrollLeft", 1.0f); OSCmessageScrollLeft.Send(myDetector); } } else if (gesture.Name.Equals(this.zoomInGestureName)) { zoomIn = result.Detected; if (zoomIn = result.Detected) { OscMessage OSCmessageZoomIn = new OscMessage(myDetector, "/ZoomIn", 1.0f); OSCmessageZoomIn.Send(myDetector); } } else if (gesture.Name.Equals(this.zoomOutGestureName)) { zoomOut = result.Detected; if (zoomOut = result.Detected) { OscMessage OSCmessageZoomOut = new OscMessage(myDetector, "/ZoomOut", 1.0f); OSCmessageZoomOut.Send(myDetector); } } else if (gesture.Name.Equals(this.pointUpGestureName)) { upButton = result.Detected; if (upButton = result.Detected) { OscMessage OSCmessagePointUp = new OscMessage(myDetector, "/PointUp", 1.0f); OSCmessagePointUp.Send(myDetector); System.Threading.Thread.Sleep(1000); } } else if (gesture.Name.Equals(this.pointDownGestureName)) { downButton = result.Detected; if (downButton = result.Detected) { OscMessage OSCmessagePointDown = new OscMessage(myDetector, "/PointDown", 1.0f); OSCmessagePointDown.Send(myDetector); System.Threading.Thread.Sleep(1000); } } else if (gesture.Name.Equals(this.pointMiddleGestureName)) { middleButton = result.Detected; if (middleButton = result.Detected) { OscMessage OSCmessagePointMiddle = new OscMessage(myDetector, "/PointMiddle", 1.0f); OSCmessagePointMiddle.Send(myDetector); System.Threading.Thread.Sleep(1000); } } else if (gesture.Name.Equals(this.startGestureName)) { startApp = result.Detected; if (startApp = result.Detected) { OscMessage OSCmessageStart = new OscMessage(myDetector, "/Start", 1.0f); OSCmessageStart.Send(myDetector); System.Threading.Thread.Sleep(1000); } } } } // It gives a value for each continuous gesture ZOOMING & SCROLLING if (continuousResults != null) { if (gesture.Name.Equals(this.scrollProgressGestureName) && gesture.GestureType == GestureType.Continuous) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { scrollProgress = result.Progress; if (scrollUp || scrollDown) { OscMessage OSCmessagescrollProgress = new OscMessage(myDetector, "/ScrollProgress", scrollProgress); OSCmessagescrollProgress.Send(myDetector); } } } if (gesture.Name.Equals(this.scrollSideProgressGestureName) && gesture.GestureType == GestureType.Continuous) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { scrollSideProgress = result.Progress; if (scrollRight || scrollLeft) { OscMessage OSCmessagescrollSideProgress = new OscMessage(myDetector, "/ScrollSideProgress", scrollProgress); OSCmessagescrollSideProgress.Send(myDetector); } } } if (gesture.Name.Equals(this.zoomProgressGestureName) && gesture.GestureType == GestureType.Continuous) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { zoomProgress = result.Progress; if (zoomIn || zoomOut) { OscMessage OSCmessagezoomProgress = new OscMessage(myDetector, "/ZoomProgress", zoomProgress); OSCmessagezoomProgress.Send(myDetector); } } } } } // clamp the progress value between 0 and 1 if (scrollProgress < 0) { scrollProgress = 0; } else if (scrollProgress > 1) { scrollProgress = 1; } if (scrollSideProgress < 0) { scrollSideProgress = 0; } else if (scrollSideProgress > 1) { scrollSideProgress = 1; } // clamp the progress value between 0 and 1 if (zoomProgress < 0) { zoomProgress = 0; } else if (zoomProgress > 1) { zoomProgress = 1; } // Continuous gestures will always report a value while the body is tracked. // We need to provide context to this value by mapping it to one or more discrete gestures. // For this sample, we will ignore the progress value whenever the user is not performing any of the discrete gestures. if (!zoomIn && !zoomOut) { zoomProgress = -1; } if (!scrollUp && !scrollDown) { scrollProgress = -1; } if (!scrollRight && !scrollLeft) { scrollSideProgress = -1; } // update the UI with the latest gesture detection results this.GestureResultView.UpdateGestureResult(false, false, false, false, false, -1.0f, -1.0f, false, false, -1.0f, false, false, false, false); } } } }
/// 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); } } } } } } } }
// Handle 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 (var frame = vgbFrameReader.CalculateAndAcquireLatestFrame()) { bool anyGestureDetected = false; bool stopDetected = false; bool skipDetected = false; bool backDetected = false; bool vupDetected = false; bool vdownDetected = false; float progress = 0; if (frame != null) { // Get gestures results var discreteResults = frame.DiscreteGestureResults; var continuousResults = frame.ContinuousGestureResults; if (discreteResults != null) { foreach (Gesture gesture in vgbFrameSource.Gestures) { if (gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { Console.WriteLine("Discrete Gesture"); anyGestureDetected = false; } } } } if (continuousResults != null) { foreach (Gesture gesture in vgbFrameSource.Gestures) { if (gesture.Name.Equals(stop) || gesture.Name.Equals(back) || gesture.Name.Equals(skip) || gesture.Name.Equals(vdown) || gesture.Name.Equals(vup)) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { progress = result.Progress; if (progress >= 1) { count++; if (count != 15) { return; } count = 0; if (gesture.Name.Equals(stop)) { sendMessage("PAUSE", progress); anyGestureDetected = true; stopDetected = true; skipDetected = false; backDetected = false; vupDetected = false; vdownDetected = false; } else if (gesture.Name.Equals(skip)) { sendMessage("BACK", progress); anyGestureDetected = true; stopDetected = false; skipDetected = true; backDetected = false; vupDetected = false; vdownDetected = false; } else if (gesture.Name.Equals(back)) { sendMessage("SKIP", progress); anyGestureDetected = true; stopDetected = false; skipDetected = false; backDetected = true; vupDetected = false; vdownDetected = false; } else if (gesture.Name.Equals(vup)) { sendMessage("VUP", progress); anyGestureDetected = true; stopDetected = false; skipDetected = false; backDetected = false; vupDetected = true; vdownDetected = false; } else if (gesture.Name.Equals(vdown)) { sendMessage("VDOWN", progress); anyGestureDetected = true; stopDetected = false; skipDetected = false; backDetected = false; vupDetected = false; vdownDetected = true; } } } } } } GestureResultView.UpdateGestureResult(true, anyGestureDetected, stopDetected, skipDetected, backDetected, vupDetected, vdownDetected, progress); } } }
public void UpdateGestureData() { using (var frame = this.vgbFrameReader.CalculateAndAcquireLatestFrame()) { if (frame != null) { //this.word.Text = "AQUI ANDO"; // 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 this.vgbFrameSource.Gestures) { if (gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { switch (gesture.Name) { case "relajado": if (result.Detected) { if (result.Confidence > 0.85) { AllFalse(); continue; } } break; case abrir_inico: if (result.Detected) { abrirIniciado = result.Detected; } break; case abrir_final: if (result.Detected) { abrirFinal = result.Detected; } break; case aparecer_inicio: if (result.Detected) { boolAparecerInicio = result.Detected; } break; case aparecer_final: if (result.Detected) { boolAparecerFinal = result.Detected; } break; case borrego_inicio: if (result.Detected) { boolBorregoInicio = result.Detected; } break; case borrego_final: if (result.Detected) { boolBorregoFinal = result.Detected; } break; case cuadrado_inicio: if (result.Detected) { boolCuadradoInicio = result.Detected; } break; case cuadrado_mitad: if (result.Detected) { boolCuadradoMitad = result.Detected; } break; case cuadrado_final: if (result.Detected) { boolCuadradoFinal = result.Detected; } break; case harina_inicio: if (result.Detected) { boolHarinaInicio = result.Detected; } break; case harina_final: if (result.Detected) { boolHarinaFinal = result.Detected; } break; case lunes_inicio: if (result.Detected) { boolLunes = result.Detected; } break; case miercoles_inicio: if (result.Detected) { boolMiercoles = result.Detected; } break; case rapido_inicio: if (result.Detected) { boolRapidoInicio = result.Detected; } break; case rapido_final: if (result.Detected) { boolRapidoFinal = result.Detected; } break; case taco_inicio: if (result.Detected) { boolTacoInicio = result.Detected; } break; case taco_final: if (result.Detected) { boolTacoFinal = result.Detected; } break; case yo: if (result.Detected) { boolYo = result.Detected; } break; } } } if (continuousResults != null) { if (gesture.GestureType == GestureType.Continuous) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { switch (gesture.Name) { case abrirProgress: abrirProgreso = result.Progress; break; case aparecerProgress: progresoAparecer = result.Progress; break; case borregoProgress: progresoBorrego = result.Progress; break; case cuadradoProgress: progresoCuadrado = result.Progress; break; case harinaProgress: progresoHarina = result.Progress; break; case lunesProgress: progresoLunes = result.Progress; break; case miercolesProgress: progresoMiercoles = result.Progress; break; case rapidoProgress: progresoRapido = result.Progress; break; case tacoProgress: progresoTaco = result.Progress; break; } } } } } if (abrirIniciado && abrirFinal && abrirProgreso > 0.8f) { this.word.Text = "ABRIR"; } else if (boolAparecerInicio && boolAparecerFinal && progresoAparecer > 0.8f) { this.word.Text = "APARECER"; } else if (boolBorregoInicio && boolBorregoFinal && progresoBorrego > 0.8f) { this.word.Text = "BORREGO"; } else if (boolCuadradoInicio && boolCuadradoMitad && boolCuadradoFinal && progresoCuadrado > 0.8f) { this.word.Text = "CUADRADO"; } else if (boolHarinaInicio && boolHarinaFinal && progresoHarina > 0.8f) { this.word.Text = "HARINA"; } else if (boolLunes && progresoLunes > 0.8f) { this.word.Text = "LUNES"; } else if (boolMiercoles && progresoMiercoles > 0.8f) { this.word.Text = "MIERCOLES"; } else if (boolRapidoInicio && boolRapidoFinal && progresoRapido > 0.8f) { this.word.Text = "RAPIDO"; } else if (boolTacoInicio && boolTacoFinal && progresoTaco > 0.8f) { this.word.Text = "TACO"; } else if (boolYo) { this.word.Text = "YO"; } else { this.word.Text = "ESPERANDO"; } } } } }
/// <summary> /// Retrieves the latest gesture detection results from the sensor /// </summary> public void UpdateGestureData() { using (var frame = this.vgbFrameReader.CalculateAndAcquireLatestFrame()) { 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) { bool maxTurnLeft = false; bool maxTurnRight = false; bool steerLeft = this.GestureResultView.TurnLeft; bool steerRight = this.GestureResultView.TurnRight; bool keepStraight = this.GestureResultView.KeepStraight; float steerProgress = this.GestureResultView.SteerProgress; foreach (var gesture in this.vgbFrameSource.Gestures) { if (gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { if (gesture.Name.Equals(this.steerLeftGestureName)) { steerLeft = result.Detected; } else if (gesture.Name.Equals(this.steerRightGestureName)) { steerRight = result.Detected; } else if (gesture.Name.Equals(this.maxTurnLeftGestureName)) { maxTurnLeft = result.Detected; } else if (gesture.Name.Equals(this.maxTurnRightGestureName)) { maxTurnRight = result.Detected; } } } if (continuousResults != null) { if (gesture.Name.Equals(this.steerProgressGestureName) && gesture.GestureType == GestureType.Continuous) { ContinuousGestureResult result = null; continuousResults.TryGetValue(gesture, out result); if (result != null) { steerProgress = result.Progress; } } } } // use handstate to determine if the user is holding the steering wheel // note: we could use a combination of the 'SteerStraight' 'Return_Left' and 'Return_Right' gestures here, // but in this case, handstate is easier to detect and does essentially the same thing keepStraight = this.ClosedHandState; // if either the 'Steer_Left' or 'MaxTurn_Left' gesture is detected, then we want to turn the ship left if (steerLeft || maxTurnLeft) { steerLeft = true; keepStraight = false; } // if either the 'Steer_Right' or 'MaxTurn_Right' gesture is detected, then we want to turn the ship right if (steerRight || maxTurnRight) { steerRight = true; keepStraight = false; } // clamp the progress value between 0 and 1 if (steerProgress < 0) { steerProgress = 0; } else if (steerProgress > 1) { steerProgress = 1; } // Continuous gestures will always report a value while the body is tracked. // We need to provide context to this value by mapping it to one or more discrete gestures. // For this sample, we will ignore the progress value whenever the user is not performing any of the discrete gestures. if (!steerLeft && !steerRight && !keepStraight) { steerProgress = -1; } // update the UI with the latest gesture detection results this.GestureResultView.UpdateGestureResult(true, steerLeft, steerRight, keepStraight, steerProgress); } } } }
/// <summary> /// Converts the default continuous result list to a list where gestures have been linked. /// </summary> /// <param name="aResultList">A list of unlinked gesture results</param> /// <returns>A dictionairy that uses PseudoGesture names to search for their continuous values</returns> public Dictionary <string, float> getLinkedContinuousResult(IReadOnlyDictionary <Gesture, ContinuousGestureResult> aResultList) { Dictionary <string, float> returnDict = null; if (aResultList != null) { returnDict = new Dictionary <string, float>(); GestureLink tempLink = null; bool ignored = false; foreach (KeyValuePair <Gesture, ContinuousGestureResult> contResult in aResultList) { ignored = false; tempLink = null; if (conf != null) { //check if the current gesture should be ignored foreach (string s in conf.ignoreList) { if (s.Equals(contResult.Key.Name)) { ignored = true; break; } } //check if the current gesture from VGBsource is included in a link from the config if (!ignored) { tempLink = conf.findGestureInLink(contResult.Key.Name);//null if not included } } //was it included? if (tempLink != null) { //if the dictionairy doesn't contain a gesture that represents a link, add a gesture to work as the link if (!returnDict.ContainsKey(tempLink.commonName)) { //In case of a link that is available, we only want to know the confidence of the gesture with highest confidence //so in order to do that, we need to find out which of the gestures in a link have the highest confidence ContinuousGestureResult gestResult = null; float highestProgress = 0; //read all gesturenames from the linked gestures list foreach (string gestureName in tempLink.linkedGesturesList) { //search trough the result dictionairy to find the correct gesture confidence foreach (KeyValuePair <Gesture, ContinuousGestureResult> gesture in aResultList) { //find the gesture that has the same name as the current gesture we got from the link list if (gesture.Key.Name.Equals(gestureName)) { //read out the confidence this gesture has aResultList.TryGetValue(gesture.Key, out gestResult); //check if this gesture has the highest confidence if (highestProgress < gestResult.Progress) { //if so set this confidence as the final confidence highestProgress = gestResult.Progress; } //we found the gesture we wanted, no need to search trough the dictionary anymore break; } } } returnDict.Add(tempLink.commonName, highestProgress); } } else { if (!ignored) { //if the gesture wasn't included in a link, we can add it directly to the returnDict ContinuousGestureResult gestResult = null; aResultList.TryGetValue(contResult.Key, out gestResult); returnDict.Add(contResult.Key.Name, gestResult.Progress); } } } } return(returnDict); }
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 }