// **************************************************these are called every frame************************************************************ private void GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) //for each GestureReader Event { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { IDictionary <Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; // get the discrete gesture results which arrived with the latest frame // retrun Gesture check the unity gesture scripts if (HashIdtb.ContainsKey(frame.TrackingId) && discreteResults != null && PlayerArgs.ContainsKey(frame.TrackingId)) { Dictionary <VisualGestureBuilderFrameSource, VisualGestureBuilderFrameReader> thisGestureGroup = HashIdtb[frame.TrackingId] as Dictionary <VisualGestureBuilderFrameSource, VisualGestureBuilderFrameReader>; foreach (var GestureGroup in thisGestureGroup) // we actually only have 1 group, should i use a struct or something else? { var thisSource = GestureGroup.Key; foreach (Gesture gesture in thisSource.Gestures) //all the gesture in gesturedatabase { if (gesture.GestureType == GestureType.Discrete) //check the type { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (OnGestureData != null) //we emit event EVERY GESTURE RESULT { OnGestureData(this, new KinectGestureDataEvent(gesture.Name, result.Confidence, frame.TrackingId, PlayerArgs[frame.TrackingId])); } } } } } } } }
// 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) { // 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) { /**********************************************************************************************/ //Cuando el gesto es reconocido reproduce el sonido this.ReproducirSonido(result.Detected, result.Confidence); /**********************************************************************************************/ } } } } } } }
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)); } } } } } } } }
/// <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.seatedGestureName) && 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); //Update DB } } } } } } }
/// <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) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { if (result.Confidence > 0 && gesture.GestureType == GestureType.Discrete) //gesture.Name.Equals(this.crossedArms) { // System.Diagnostics.Debug.WriteLine(vgbFrameSource.TrackingId); // update the GestureResultView object with new gesture result values this.GestureResultView.UpdateGestureResult(gesture.Name, true, result.Detected, result.Confidence); } if (result.Confidence < 0.15) { this.GestureResultView.UpdateGestureResult(gesture.Name, true, result.Detected, 0); } } } } } } }
private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { //Get the gesture results from the last 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) { this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence); } } } } } } }
void FrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { if (canPose) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null && frame.DiscreteGestureResults != null) { DiscreteGestureResult result = null; if (frame.DiscreteGestureResults.Count > 0) //if there is one or more potential gesture being detected by the kinect { for (int i = 0; i < gestures.Count; i++) //for each gesture in the database { result = frame.DiscreteGestureResults[gestures[i].gesture]; //get the result of gesture i if (result.Detected == true) //if gesture i was detected { // gestures[i].trigger.Invoke();//call the unityevent attacked to the gesture Model.SetActive(true); Model.GetComponent <MeshFilter>().mesh = gestures[i].mesh; StopCapture(); } } } } } } }
void _gestureFrameReader_FrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null && frame.DiscreteGestureResults != null) { DiscreteGestureResult result = null; if (frame.DiscreteGestureResults.Count > 0) { result = frame.DiscreteGestureResults [_menu]; } if (result == null | !menuGestureOk) { return; } if (result.Detected == true & buttonPushed < Time.time - 1f) { source.PlayOneShot(menuToggled, 0.5f); menu.enabled = !menu.enabled; //hide show menu buttonPushed = Time.time; } } } }
/// 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; if (discreteResults != null) { foreach (Gesture gesture in _Source.Gestures) { if (gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result.Confidence > 0.05) { // Fire Event if (OnGesture != null) { Debug.Log("Detected Gesture " + gesture.Name + " with Confidence " + result.Confidence); OnGesture(this, new KinectGestureEvent(gesture.Name, 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.GestureClapping) && 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.GestureClapping)); } } } if (gesture.Name.Equals(this.GestureHandShake_Right) && 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.GestureHandShake_Right)); } } } if (gesture.Name.Equals(this.GestureLeftRotation_Right) && 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.GestureHandShake_Right)); } } } } } } } }
void _gestureFrameReader_FrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null && frame.DiscreteGestureResults != null) { DiscreteGestureResult result = null; if (frame.DiscreteGestureResults.Count > 0) { foreach (Gesture gesture in trackedGestures) { result = frame.DiscreteGestureResults[gesture]; if (result != null) { if (result.Detected == true) { //if(result.Confidence > 0.60f) { Debug.Log("Detected: " + gesture.Name); //Debug.Log("result confidence: " +result.Confidence); } } } } } } } }
private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null) { //Get the gesture results from the last frame IReadOnlyDictionary <Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { foreach (Gesture gesture in this.vgbFrameSource.Gestures) { if (gesture.Name.Equals(this.waveName) && gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null && result.Confidence > 0.8) //Limit the amount of results which are reported back, by setting a minimum confidence level { if (result.Confidence == 1) { this.GestureResultView.GestureCount++; } this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence); //Report back the updated gesture result } } } } } } }
/// 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; if (discreteResults != null) { foreach (Gesture gesture in _Source.Gestures) { if (gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (gesture.Name == "point_right") { GameObject.Find("CreateDiagram").GetComponent <HistogramTexture> ().setHeight(result.Confidence); } /*if (result.Confidence > 0.05) { * // Fire Event * if(OnGesture!=null){ * // Debug.Log("Detected Gesture " + gesture.Name + " with Confidence " + result.Confidence); * // OnGesture(this,new KinectGestureEvent(gesture.Name, 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) { // percorrer dicionario à procura do gesto discreto com maior confiança // não gosto mas como escolher o melhor gesto? // get the discrete gesture results which arrived with the latest frame IReadOnlyDictionary <Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; // get the discrete gesture results which arrived with the latest frame IReadOnlyDictionary <Gesture, ContinuousGestureResult> continuousResults = frame.ContinuousGestureResults; if (discreteResults != null && !serverPipe.IsSpeakRunning) { string result = gFrameHandler.handleFrame(discreteResults); if (result != null) { gestureSelection(result.Split('_')[0]); Console.WriteLine("Result: " + result); } } } } }
/// <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) { Parallel.ForEach(this.vgbFrameSource.Gestures, gesture => { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result.Detected) { gestureActions[gesture.Name].Invoke(); } else if (gesture.Name == "Block") { Release(NesButtons.Down); } }); } } } }
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); } } } } } }
/// Handles gesture detection results arriving from the sensor for the associated body tracking Id protected virtual 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 _Source.Gestures) { if (gesture.GestureType == GestureType.Discrete) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { // Fire Event if (result.Detected) { //Debug.Log("Detected Gesture " + gesture.Name + " with Confidence " + result.Confidence); if (result.Confidence >= MinConfidence) { DetectedConfidence = result.Confidence; this.CurrentGestureName = gesture.Name; DetectedWork(); OnGesture(new EventArgs(gesture.Name, result.Confidence)); } else { this.CurrentGestureName = string.Empty; this.DetectedConfidence = 0.0f; } } else { this.CurrentGestureName = string.Empty; this.DetectedConfidence = 0.0f; NotDetectedWork(); } // OnGesture(new EventArgs(gesture.Name, result.Confidence)); // } } } } } } }
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) { Gesture localGesture = null; 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) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { if (result.Detected) { localGesture = gesture; } // update the GestureResultView object with new gesture result values //this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence); } } } } } if (currentWantedGesture == gestureNames.Length) { OnGestureFired?.Invoke(); currentWantedGesture = 0; lastGesture = null; return; } if (gestureNames[currentWantedGesture] == localGesture?.Name) { lastGesture = localGesture; lastCoolGesture = DateTime.UtcNow; currentWantedGesture++; return; } if (lastGesture != null && DateTime.UtcNow - lastCoolGesture > TimeSpan.FromSeconds(5)) { currentWantedGesture = 0; lastGesture = null; } }
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> /// This function reads every input frame from Kinect using VisualGestureBuilder API /// A valid frame is stored in an array as soon as it is received /// recordbodydata is a flag that is a boundary condition to record the coordinates to know about the status of last detected frame. /// The 'result' is set to true when gesture received from frame matches either start or end position of gestures /// The function passes to DTW for sequence matching when the start and end position are of same gesture. /// </summary> 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; 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) { this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence); } try { //conditional statement to record body data if (RECORD_BODY_DATA == RECORD && result.Detected == false) { storebodycoordinates();//stores current frame } else if (result != null && result.Detected == true && result.Confidence >= 0.6) { if (KINECT_COORDINATES.Length != 0) { string result_gesture = passToDTW(); RECORD_BODY_DATA = EMPTY; break; } RECORD_BODY_DATA = RECORD; } } catch (Exception ex) { //do nothing } } } } } } }
/// <summary> /// This function reads every input frame from Kinect using VisualGestureBuilder API /// A valid frame is stored in an array as soon as it is received /// recordbodydata is a flag that is a boundary condition to record the coordinates to know about the status of last detected frame. /// The 'result' is set to true when gesture received from frame matches either start or end position of gestures /// The function passes to DTW for sequence matching when the start and end position are of same gesture. /// </summary> 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; 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) { this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence); } try { if (lastdetected == 1 && result.Detected == false) { storebodycoordinates(); } else if (result != null && result.Detected == true && result.Confidence >= 0.6) { if (KINECT_COORDINATES.Length != 0 && lastcountdetected == 0) { SaveToFile(KINECT_COORDINATES); lastdetected = 0; lastcountdetected = 1; break; } lastdetected = 1; } } catch (Exception ex) { } } } } } } }
private void gestureFrameReader_FrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null && waitingForOp()) { IReadOnlyDictionary <Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults; if (discreteResults != null) { foreach (Gesture gesture in this.gestureFrameSource.Gestures) { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null && result.Detected) { switch (gesture.Name) { case "Plus": if (result.Confidence > 0.8) { AddOperator("+"); } break; case "Minus": if (result.Confidence > 0.95) { AddOperator("-"); } break; case "Times": if (result.Confidence > 0.90) { AddOperator("*"); } break; case "divide": if (result.Confidence > 0.90) { AddOperator("/"); } break; } } } } } } }
void _gestureFrameReader_FrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null && frame.DiscreteGestureResults != null) { if (AttachedObject == null) { return; } DiscreteGestureResult result = null; if (frame.DiscreteGestureResults.Count > 0) { result = frame.DiscreteGestureResults[_salute]; } if (result == null) { return; } if (result.Detected == true) { var progressResult = frame.ContinuousGestureResults[_saluteProgress]; if (AttachedObject != null) { var prog = progressResult.Progress; float scale = 0.5f + prog * 3.0f; AttachedObject.transform.localScale = new Vector3(scale, scale, scale); if (_ps != null) { _ps.emissionRate = 100 * prog; _ps.startColor = Color.red; } } } else { if (_ps != null) { _ps.emissionRate = 4; _ps.startColor = Color.blue; } } } } }
/// 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; if (discreteResults != null) { List <EventArgs> Results = new List <EventArgs>(); foreach (Gesture gesture in _Source.Gestures) { //Debug.Log(gesture.Name); //Debug.Log(gesture.GestureType); if (gesture.GestureType == GestureType.Discrete) //离散型 { DiscreteGestureResult result = null; discreteResults.TryGetValue(gesture, out result); if (result != null) { if (IsDetected(Priority[gesture.Name], result.Confidence)) //该动作是否完成 { Results.Add(new EventArgs(gesture.Name, result.Confidence)); //完成则加入判断列表 //Debug.Log("Detected Gesture " + gesture.Name + " with Confidence " + result.Confidence); // Fire Event //OnGesture(new EventArgs(gesture.Name, result.Confidence)); //return; } } } } EventArgs Result = GestureJudgement(Results); Debug.Log("Detected Gesture " + Result.name + " with Confidence " + Result.confidence.ToString()); OnGesture(Result); } } //OnGesture(new EventArgs("NO-Gesture", 0)); } }
/// <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 }
void _gestureFrameReader_FrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null && frame.DiscreteGestureResults != null) { gesture1 = gesture2 = gesture3 = gesture4 = null; gesture1 = frame.DiscreteGestureResults[_gesture1]; gesture2 = frame.DiscreteGestureResults[_gesture2]; Do_things(frame); } } }
/// <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); } } } } } } } }
void _gestureFrameReader_FrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e) { VisualGestureBuilderFrameReference frameReference = e.FrameReference; using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame()) { if (frame != null && frame.DiscreteGestureResults != null) { result = frame.DiscreteGestureResults [wavehand_right]; } if (result == null) { return; } if (result.Detected == true && result.Confidence > 0.95) { } } }
/// <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.SkipSongLeft) || gesture.Name.Equals(this.SkipSongRight)) && gesture.GestureType == GestureType.Discrete) { //Left Arm Next song FALSE Right Arm Previous Song TRUE if (gesture.Name.Equals(this.SkipSongLeft)) { skipSong = false; } else { skipSong = true; } 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.vgbFrameReader.IsPaused = this.GestureResultView.GestureResponse(true, result.Detected, result.Confidence, skipSong); this.vgbFrameReader.IsPaused = false; } } } } } } }