/// <summary>
        /// Callback when posture is detected
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        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)
                    {
                        Dictionary <string, float> gestures = new Dictionary <string, float>();

                        MainWindow.persons[index].postures.Clear();

                        foreach (Gesture gesture in vgbFrameSource.Gestures)
                        {
                            if (gesture.GestureType == GestureType.Discrete)
                            {
                                DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);

                                if (result != null)
                                {
                                    if (result.Detected)
                                    {
                                        gestures.Add(gesture.Name, result.Confidence);
                                        MainWindow.persons[index].postures.AddLast(new Posture(gesture.Name));
                                    }
                                }
                            }
                        }

                        //Plot.DrawGesturesOnCanvas(MainWindow.persons[index], gestures, canvas);
                    }
                }
            }
        }
예제 #2
0
        private void OnGestureFrameArrived(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 crossResult = null;
                        discreteResults.TryGetValue(GesturesDictionary["Cross"], out crossResult);


                        // Cross detection
                        if (crossResult.Detected && crossResult.Confidence > CONFIDENCE_THRESHOLD && !CrossDetected)
                        {
                            CrossDetected = true;
                            Console.WriteLine("Cross");
                            ApplicationService.Instance.Cross();
                            CrossDetectedInRow = CROSS_DETECTION_THRESHOLD;
                        }
                        else if (!crossResult.Detected)
                        {
                            if (CrossDetectedInRow == 0)
                            {
                                CrossDetected = false;
                            }
                            else
                            {
                                CrossDetectedInRow--;
                            }
                        }
                    }
                }
            }
        }
예제 #3
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)
        {
            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.flapGestureName) && 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);
                                    if (result.Detected && result.Confidence > 0.5)
                                    {
                                        WebClient.alertFlapDetected();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
        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.Name.Equals("come") || gesture.Name.Equals("follow") || gesture.Name.Equals("sync"))
                            {
                                DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);


                                if (result != null)
                                {
                                    this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence);

                                    if (result.Detected)
                                    {
                                        switch (gesture.Name)
                                        {
                                        case "follow":
                                        {
                                            if (GestureAndSpeech.follow[0])
                                            {
                                                printNew = "follow pingo speech & gesture";
                                                if (printNew != printOld)
                                                {
                                                    Server.sendClient1("follow");
                                                    Console.WriteLine(printNew);
                                                }
                                                printOld = printNew;
                                            }
                                            else if (GestureAndSpeech.follow[1])
                                            {
                                                printNew = "follow max speech & gesture";
                                                if (printNew != printOld)
                                                {
                                                    Server.sendClient2("follow");
                                                    Console.WriteLine(printNew);
                                                }
                                                printOld = printNew;
                                            }
                                        }
                                        break;

                                        case "fetchGest":
                                        {
                                            if (GestureAndSpeech.fetch[0])
                                            {
                                                printNew = "fetch pingo speech & gesture";
                                                if (printNew != printOld)
                                                {
                                                    Server.sendClient1("fetch");
                                                    Console.WriteLine(printNew);
                                                }
                                                printOld = printNew;
                                            }
                                            else if (GestureAndSpeech.fetch[1])
                                            {
                                                printNew = "fetch max speech & gesture";
                                                if (printNew != printOld)
                                                {
                                                    Server.sendClient2("fetch");
                                                    Console.WriteLine(printNew);
                                                }
                                                printOld = printNew;
                                            }
                                        }
                                        break;

                                        case "come":
                                        {
                                            if (GestureAndSpeech.come[0])
                                            {
                                                printNew = "come pingo speech & gesture";
                                                if (printNew != printOld)
                                                {
                                                    Server.sendClient1("come");
                                                    Console.WriteLine(printNew);
                                                }
                                                printOld = printNew;
                                            }
                                            else if (GestureAndSpeech.come[1])
                                            {
                                                printNew = "come max speech & gesture";
                                                if (printNew != printOld)
                                                {
                                                    Server.sendClient2("come");
                                                    Console.WriteLine(printNew);
                                                }
                                                printOld = printNew;
                                            }
                                            else if (GestureAndSpeech.come[2])
                                            {
                                                printNew = "come both speech & gesture";
                                                if (printNew != printOld)
                                                {
                                                    Server.sendClient1("come");
                                                    Server.sendClient2("come");
                                                    Console.WriteLine(printNew);
                                                }
                                                printOld = printNew;
                                            }
                                        }
                                        break;

                                        case "sync":
                                        {
                                            if (GestureAndSpeech.sync)
                                            {
                                                printNew = "sync both speech & gesture";
                                                if (printNew != printOld)
                                                {
                                                    Server.sendClient1("synchronize");
                                                    Server.sendClient2("synchronize");
                                                    Console.WriteLine(printNew);
                                                }
                                                printOld = printNew;
                                            }
                                        }
                                        break;

                                        default: break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <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 bool SwipeOnRight = false;
        //private bool SwipeOnLeft = false;

        //void Monitor_SwipeOnRight(bool mode)
        //{
        //    if (SwipeOnRight == false && mode == true)
        //    {
        //        SwipeOnRight = true;
        //    }
        //}

        //void Monitor_SwipeOnLeft(bool mode)
        //{
        //    if (SwipeOnLeft == false && mode == true)
        //    {
        //        SwipeOnLeft = true;
        //    }
        //}

        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.swipeRightGestureName) && gesture.GestureType == GestureType.Discrete)
                        //    {
                        //        DiscreteGestureResult result = null;
                        //        discreteResults.TryGetValue(gesture, out result);

                        //        if (result.Confidence == 1.0f)
                        //        {
                        //            Monitor_SwipeOnRight(true);
                        //        }

                        //        else if (result.Confidence == 0.0f && SwipeOnRight == true)
                        //        {
                        //            SwipeOnRight = false;
                        //            Console.WriteLine("false");
                        //        }

                        //        //if (result != null)
                        //        //{
                        //        //    // update the GestureResultView object with new gesture result values
                        //        //    this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.swipeRightGestureName);
                        //        //}
                        //    }

                        //    if (gesture.Name.Equals(this.swipeLeftGestureName) && gesture.GestureType == GestureType.Discrete)
                        //    {
                        //        DiscreteGestureResult result = null;
                        //        discreteResults.TryGetValue(gesture, out result);

                        //        if (result.Confidence == 1.0f)
                        //        {
                        //            Monitor_SwipeOnLeft(true);
                        //        }

                        //        else if (result.Confidence == 0.0f && SwipeOnLeft == true)
                        //        {
                        //            SwipeOnLeft = false;
                        //            Console.WriteLine("false");
                        //        }

                        //        //if (result != null)
                        //        //{
                        //        //    // update the GestureResultView object with new gesture result values
                        //        //    this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.swipeRightGestureName);
                        //        //}
                        //    }

                        // 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.swipeRightGestureName) && gesture.GestureType == GestureType.Discrete)
                            {
                                DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);

                                if (result.Confidence == 1.0f)
                                {
                                    ThisAddIn.Monitor_SwipeOnRight(true);
                                }

                                else if (result.Confidence == 0.0f && ThisAddIn.SwipeOnRight == true)
                                {
                                    ThisAddIn.SwipeOnRight = false;
                                }

                                //if (result != null)
                                //{
                                //    // update the GestureResultView object with new gesture result values
                                //    this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.swipeRightGestureName);
                                //}
                            }

                            if (gesture.Name.Equals(this.swipeLeftGestureName) && gesture.GestureType == GestureType.Discrete)
                            {
                                DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);

                                if (result.Confidence == 1.0f)
                                {
                                    ThisAddIn.Monitor_SwipeOnLeft(true);
                                }

                                else if (result.Confidence == 0.0f && ThisAddIn.SwipeOnLeft == true)
                                {
                                    ThisAddIn.SwipeOnLeft = false;
                                    Console.WriteLine("false");
                                }

                                //if (result != null)
                                //{
                                //    // update the GestureResultView object with new gesture result values
                                //    this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.swipeRightGestureName);
                                //}
                            }

                            //if (gesture.Name.Equals(this.swipeRightGestureName) && 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.swipeRightGestureName);
                            //    }
                            //}

                            //if (gesture.Name.Equals(this.swipeLeftGestureName) && 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.swipeLeftGestureName);
                            //    }
                            //}
                        }
                    }
                }
            }
        }
예제 #6
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)
    {
        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;
                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.Name.Equals(this.LiftHandProgressName) && gesture.GestureType == GestureType.Continuous)
                             * {
                             *  ContinuousGestureResult result = null;
                             *  continuousResults.TryGetValue(gesture, out result);
                             *
                             *  if (result != null)
                             *  {
                             *      if(result.Progress > 0.5f)
                             *      {
                             *          gestureprogress = 1;
                             *      }
                             *
                             *      if (result.Progress < 0.5f)
                             *      {
                             *          gestureprogress = 0;
                             *      }
                             *
                             *      //kinectmanager.gestureprogress = this.gestureprogress;
                             *  }
                             * }*/
                        }

                        if (gesture.GestureType == GestureType.Discrete)
                        {
                            DiscreteGestureResult result = null;
                            discreteResults.TryGetValue(gesture, out result);
                            if (result != null)
                            {
                                /*
                                 * if (gesture.Name.Equals(this.BridgeName))
                                 * {
                                 *  if (this.OnGestureDetected != null)
                                 *  {
                                 *      this.OnGestureDetected(this, new GestureEventArgs(true, result.Detected, result.Confidence, this.BridgeName));
                                 *  }
                                 * }
                                 *
                                 * if (gesture.Name.Equals(this.BridgeDownName))
                                 * {
                                 *  if (this.OnGestureDetected != null)
                                 *  {
                                 *      this.OnGestureDetected(this, new GestureEventArgs(true, result.Detected, result.Confidence, this.BridgeDownName));
                                 *  }
                                 * }
                                 */
                                if (gesture.Name.Equals(this.DigName))
                                {
                                    if (this.OnGestureDetected != null)
                                    {
                                        this.OnGestureDetected(this, new GestureEventArgs(true, result.Detected, result.Confidence, this.DigName));
                                    }
                                }
                                if (gesture.Name.Equals(this.SeedName))
                                {
                                    if (this.OnGestureDetected != null)
                                    {
                                        this.OnGestureDetected(this, new GestureEventArgs(true, result.Detected, result.Confidence, this.SeedName));
                                    }
                                }
                                if (gesture.Name.Equals(this.PutName))
                                {
                                    if (this.OnGestureDetected != null)
                                    {
                                        this.OnGestureDetected(this, new GestureEventArgs(true, result.Detected, result.Confidence, this.PutName));
                                    }
                                }
                                if (gesture.Name.Equals(this.RainName))
                                {
                                    if (this.OnGestureDetected != null)
                                    {
                                        this.OnGestureDetected(this, new GestureEventArgs(true, result.Detected, result.Confidence, this.RainName));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
        /// <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);
                        }
                    }
                }
            }
        }
        /// <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)
                    {
                        //bool hand_shake = this.GestureResultView.Hand_Shake_detected;
                        //bool hand_wave = this.GestureResultView.Hand_Wave_detected;

                        bool handwave_right1  = this.GestureResultView.Hand_wave_right_detected;
                        bool handwave_left1   = this.GestureResultView.Hand_wave_left_detected;
                        bool handshake_right1 = this.GestureResultView.Hand_shake_right_detected;
                        bool handshake_left1  = this.GestureResultView.Hand_shake_left_detected;
                        bool box1             = this.GestureResultView.box_detected;
                        bool cool1            = this.GestureResultView.cool_detected;


                        // we only have one gesture in this source object, but you can get multiple gestures
                        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.box_GestureName))
                                    {
                                        box1 = result.Detected;
                                        box  = result.Detected;
                                    }
                                    if (gesture.Name.Equals(this.cool_GestureName))
                                    {
                                        cool  = result.Detected;
                                        cool1 = result.Detected;
                                    }

                                    if (gesture.Name.Equals(this.handshake_left_GestureName))
                                    {
                                        handshake_left  = result.Detected;
                                        handshake_left1 = result.Detected;
                                    }
                                    if (gesture.Name.Equals(this.handshake_right_GestureName))
                                    {
                                        handshake_right  = result.Detected;
                                        handshake_right1 = result.Detected;
                                    }


                                    if (gesture.Name.Equals(this.handwave_left_GestureName))
                                    {
                                        handwave_left  = result.Detected;
                                        handwave_left1 = result.Detected;
                                    }


                                    if (gesture.Name.Equals(this.handwave_right_GestureName))
                                    {
                                        handwave_right  = result.Detected;
                                        handwave_right1 = result.Detected;
                                    }


                                    if (result.Detected == true)
                                    {
                                        confi = result.Confidence;
                                    }

                                    //if (gesture.Name.Equals(this.wave_handGestureName))
                                    //{
                                    //hand_wave = result.Detected;
                                    //handwave = result.Detected;

                                    //System.Diagnostics.Debug.Write("I handwave to");
                                    //System.Diagnostics.Debug.Write(result.Detected);
                                    /// HERE SHOULD BE THE POSE OF PERSON'S HEAD!!!
                                    ///hand_wave_conf = result.Confidence;
                                    //}
                                    //if (gesture.Name.Equals(this.hand_shakeGestureName))
                                    //{
                                    //this.handshakedone = result.Detected;
                                    //hand_shake = result.Detected;
                                    //System.Diagnostics.Debug.Write("I enter in hand shake and changed to");
                                    //System.Diagnostics.Debug.Write(result.Detected);
                                    ///hand_shake_conf = result.Confidence;
                                    //}
                                }
                            }
                        }
                        this.GestureResultView.UpdateGestureResult(true, box, cool, handshake_left, handshake_right, handwave_left, handwave_right, confi);
                    }
                }
            }
        }
예제 #9
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)
        {
            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
                        bool isleft = false;
                        this.GestureResultView.UpdateGestureResult(true, false, 0.0f, "");

                        foreach (Gesture gesture in this.vgbFrameSource.Gestures)
                        {
                            if (gesture.GestureType == GestureType.Discrete)
                            {
                                DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);

                                if (result != null)
                                {
                                    //  Console.WriteLine("Hello");
                                    //Console.WriteLine(gesture.Name+ " "+ result.Confidence);
                                    if (gesture.Name.Equals(this.leftledGestureName) && result.Confidence >= 0.1)
                                    {
                                        // update the GestureResultView object with new gesture result values

                                        if (leftflag == false)
                                        {
                                            leftflag = true;
                                            sp.WriteLine("256");
                                            sp.WriteLine("255");
                                        }



                                        isleft = result.Detected;
                                        this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.leftledGestureName);
                                    }

                                    if (gesture.Name.Equals(this.rightledGestureName) && result.Confidence >= 0.1)
                                    {
                                        if (rightflag == false)
                                        {
                                            rightflag = true;
                                            sp.WriteLine("257");
                                            sp.WriteLine("255");
                                        }



                                        // update the GestureResultView object with new gesture result values
                                        this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.rightledGestureName);
                                    }

                                    if (gesture.Name.Equals(this.allledoffGestureName) && result.Confidence >= 0.1)
                                    {
                                        if (leftflag == true || rightflag == true)
                                        {
                                            sp.WriteLine("500");
                                            leftflag  = false;
                                            rightflag = false;
                                        }

                                        // update the GestureResultView object with new gesture result values
                                        this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.allledoffGestureName);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #10
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)
        {
            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 && detectingGesture)
                    {
                        // 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.hotelGestureName) && gesture.GestureType == GestureType.Discrete)
                            {
                                DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);

                                if (result != null)
                                {
                                    Console.WriteLine(result.Confidence);
                                    if (result.Confidence > 0.6)
                                    {
                                        Console.WriteLine(" HOTEL GESTURE DETECTED ");
                                        SendCommand("M1");

                                        detectingGesture = false;
                                        Console.WriteLine("Kinect stoping detecting gestures.");

                                        gestureTimer           = new Timer(8 * 1000);
                                        gestureTimer.Elapsed  += OnGestureEnded;
                                        gestureTimer.AutoReset = false;
                                        gestureTimer.Enabled   = true;

                                        this.Dispatcher.Invoke(() =>
                                        {
                                            circle.Fill = System.Windows.Media.Brushes.Red;
                                        });
                                    }
                                    // update the GestureResultView object with new gesture result values
                                    this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.hotelGestureName);
                                }
                            }

                            if (gesture.Name.Equals(this.flightGestureName) && gesture.GestureType == GestureType.Discrete)
                            {
                                DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);

                                if (result != null)
                                {
                                    Console.WriteLine(result.Confidence);
                                    if (result.Confidence > 0.4)
                                    {
                                        Console.WriteLine(" FLIGHT GESTURE DETECTED ");
                                        SendCommand("M2");

                                        detectingGesture = false;
                                        Console.WriteLine("Kinect stoping detecting gestures.");

                                        gestureTimer           = new Timer(8 * 1000);
                                        gestureTimer.Elapsed  += OnGestureEnded;
                                        gestureTimer.AutoReset = false;
                                        gestureTimer.Enabled   = true;

                                        this.Dispatcher.Invoke(() =>
                                        {
                                            circle.Fill = System.Windows.Media.Brushes.Red;
                                        });
                                    }
                                    // update the GestureResultView object with new gesture result values
                                    this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.flightGestureName);
                                }
                            }

                            if (gesture.Name.Equals(this.selectGestureName) && gesture.GestureType == GestureType.Discrete)
                            {
                                DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);

                                if (result != null)
                                {
                                    Console.WriteLine(result.Confidence);
                                    if (result.Confidence > 0.4)
                                    {
                                        Console.WriteLine(" SELECT GESTURE DETECTED ");
                                        main.updateList(3);

                                        detectingGesture = false;
                                        Console.WriteLine("Kinect stoping detecting gestures.");

                                        gestureTimer           = new Timer(40 * 1000);
                                        gestureTimer.Elapsed  += OnGestureEnded;
                                        gestureTimer.AutoReset = false;
                                        gestureTimer.Enabled   = true;

                                        this.Dispatcher.Invoke(() =>
                                        {
                                            circle.Fill = System.Windows.Media.Brushes.Red;
                                        });
                                    }
                                    // update the GestureResultView object with new gesture result values
                                    this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.selectGestureName);
                                }
                            }

                            if (gesture.Name.Equals(this.upGestureName) && gesture.GestureType == GestureType.Discrete)
                            {
                                DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);

                                if (result != null)
                                {
                                    Console.WriteLine(result.Confidence);
                                    if (result.Confidence > 0.5)
                                    {
                                        Console.WriteLine(" UP GESTURE DETECTED ");
                                        main.updateList(2);

                                        detectingGesture = false;
                                        Console.WriteLine("Kinect stoping detecting gestures.");

                                        gestureTimer           = new Timer(2 * 1000);
                                        gestureTimer.Elapsed  += OnGestureEnded;
                                        gestureTimer.AutoReset = false;
                                        gestureTimer.Enabled   = true;

                                        this.Dispatcher.Invoke(() =>
                                        {
                                            circle.Fill = System.Windows.Media.Brushes.Red;
                                        });
                                    }
                                    // update the GestureResultView object with new gesture result values
                                    this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.upGestureName);
                                }
                            }

                            if (gesture.Name.Equals(this.DownGestureName) && gesture.GestureType == GestureType.Discrete)
                            {
                                DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);

                                if (result != null)
                                {
                                    Console.WriteLine(result.Confidence);
                                    if (result.Confidence > 0.4)
                                    {
                                        Console.WriteLine(" DOWN GESTURE DETECTED ");
                                        main.updateList(1);

                                        detectingGesture = false;
                                        Console.WriteLine("Kinect stoping detecting gestures.");

                                        gestureTimer           = new Timer(2 * 1000);
                                        gestureTimer.Elapsed  += OnGestureEnded;
                                        gestureTimer.AutoReset = false;
                                        gestureTimer.Enabled   = true;

                                        this.Dispatcher.Invoke(() =>
                                        {
                                            circle.Fill = System.Windows.Media.Brushes.Red;
                                        });
                                    }
                                    // update the GestureResultView object with new gesture result values
                                    this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.DownGestureName);
                                }
                            }

                            if (gesture.Name.Equals(this.ByeGestureName) && gesture.GestureType == GestureType.Discrete)
                            {
                                DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);

                                if (result != null)
                                {
                                    Console.WriteLine(result.Confidence);
                                    if (result.Confidence > 0.5)
                                    {
                                        Console.WriteLine(" BYE GESTURE DETECTED ");
                                        SendCommand("CLOSE");

                                        detectingGesture = false;
                                        Console.WriteLine("Kinect stoping detecting gestures.");

                                        gestureTimer           = new Timer(2 * 1000);
                                        gestureTimer.Elapsed  += OnGestureEnded;
                                        gestureTimer.AutoReset = false;
                                        gestureTimer.Enabled   = true;

                                        this.Dispatcher.Invoke(() =>
                                        {
                                            circle.Fill = System.Windows.Media.Brushes.Red;
                                        });

                                        Environment.Exit(0);
                                    }
                                    // update the GestureResultView object with new gesture result values
                                    this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, this.DownGestureName);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #11
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)
        {
            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);
                            //    }
                            //}

                            if (gesture.Name.Equals(this.bowingGestureName) && 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);
                                    if (result.Confidence > 0.7)
                                    {
                                        byte[] messageToSend = Encoding.ASCII.GetBytes("bow");
                                        client.Send(messageToSend, messageToSend.Length);

                                        Debug.WriteLine("bowed");
                                    }
                                }
                            }
                            else if (gesture.Name.Equals(this.raiseGestureName) && 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);
                                    if (result.Confidence > 0.7)
                                    {
                                        byte[] messageToSend = Encoding.ASCII.GetBytes("arm_up");
                                        client.Send(messageToSend, messageToSend.Length);
                                        Debug.WriteLine("raised hand");
                                    }
                                }
                            }
                            else if (gesture.Name.Equals(this.lowerGestureName) && 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);
                                    if (result.Confidence > 0.7)
                                    {
                                        byte[] messageToSend = Encoding.ASCII.GetBytes("arm_down");
                                        client.Send(messageToSend, messageToSend.Length);
                                        Debug.WriteLine("lowered hand");
                                    }
                                }
                            }
                            else
                            {
                                byte[] messageToSend = Encoding.ASCII.GetBytes("nocommand");
                                client.Send(messageToSend, messageToSend.Length);
                            }
                        }
                    }
                }
            }
        }
예제 #12
0
        private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e)
        {
            //float progress = 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)
                    {
                        foreach (Gesture gesture in vgbFrameSource.Gestures)
                        {
                            /*if(gesture.Name.Equals(this.closeTabGesture) || gesture.Name.Equals(this.goBackGesture) || gesture.Name.Equals(this.goForwardGesture) || gesture.Name.Equals(this.zoomInGesture) ||
                             *  gesture.Name.Equals(this.zoomOutGesture) || gesture.Name.Equals(this.scrollDownGesture) || gesture.Name.Equals(this.scrollUpGesture) || gesture.Name.Equals(this.refreshGesture) ||
                             *  gesture.Name.Equals(this.closeChromeGesture))
                             * {*/
                            DiscreteGestureResult result = null;
                            discreteResults.TryGetValue(gesture, out result);
                            main.SetConfidence((MaxConfidence * 100).ToString("0.00"));
                            if (result != null)
                            {
                                if ((result.Confidence >= 0.5) && (gesture.Name.Equals(this.closeChromeGesture)) && (this.gestureName != this.closeChromeGesture))
                                {
                                    this.gestureName = this.closeChromeGesture;
                                    MaxConfidence    = result.Confidence;
                                    main.SetGesture(gesture.Name);
                                    sendMessage("QUIT_CHROME");
                                    Console.WriteLine("CloseChrome");
                                }
                                else if ((result.Confidence >= 0.5) && (gesture.Name.Equals(this.closeTabGesture)) && (this.gestureName != this.closeTabGesture))
                                {
                                    this.gestureName = this.closeTabGesture;
                                    MaxConfidence    = result.Confidence;
                                    main.SetGesture(gesture.Name);
                                    sendMessage("CLOSE_TAB");
                                    Console.WriteLine("CloseTab");
                                }
                                else if ((result.Confidence >= 0.5) && (gesture.Name.Equals(this.goBackGesture)) && (this.gestureName != this.goBackGesture))
                                {
                                    this.gestureName = this.goBackGesture;
                                    MaxConfidence    = result.Confidence;
                                    main.SetGesture(gesture.Name);
                                    sendMessage("BACK");
                                    Console.WriteLine("GoBack");
                                    zoomInQuantity     = 0;
                                    zoomOutQuantity    = 0;
                                    scrollUpQuantity   = 0;
                                    scrollDownQuantity = 0;
                                }
                                else if ((result.Confidence >= 0.2) && (gesture.Name.Equals(this.goForwardGesture)) && (this.gestureName != this.goForwardGesture))
                                {
                                    this.gestureName = this.goForwardGesture;
                                    MaxConfidence    = result.Confidence;
                                    main.SetGesture(gesture.Name);
                                    sendMessage("FORWARD");
                                    Console.WriteLine("GoForward");
                                    zoomInQuantity     = 0;
                                    zoomOutQuantity    = 0;
                                    scrollUpQuantity   = 0;
                                    scrollDownQuantity = 0;
                                }
                                else if ((result.Confidence >= 0.3) && (gesture.Name.Equals(this.zoomInGesture)))
                                {
                                    this.gestureName = this.zoomInGesture;
                                    MaxConfidence    = result.Confidence;
                                    main.SetGesture(gesture.Name);
                                    if (zoomInQuantity <= 5)
                                    {
                                        sendMessage("ZOOM_IN");
                                        zoomInQuantity++;
                                    }
                                    zoomOutQuantity    = 0;
                                    scrollUpQuantity   = 0;
                                    scrollDownQuantity = 0;
                                    Console.WriteLine("ZoomIn");
                                }
                                else if ((result.Confidence >= 0.3) && (gesture.Name.Equals(this.zoomOutGesture)))
                                {
                                    this.gestureName = this.zoomOutGesture;
                                    MaxConfidence    = result.Confidence;
                                    main.SetGesture(gesture.Name);
                                    if (zoomOutQuantity <= 5)
                                    {
                                        sendMessage("ZOOM_OUT");
                                        zoomOutQuantity++;
                                    }
                                    zoomInQuantity     = 0;
                                    scrollUpQuantity   = 0;
                                    scrollDownQuantity = 0;
                                    Console.WriteLine("ZoomOut");
                                }
                                else if ((result.Confidence >= 0.6) && (gesture.Name.Equals(this.refreshGesture)) && (this.gestureName != this.refreshGesture))
                                {
                                    this.gestureName = this.refreshGesture;
                                    MaxConfidence    = result.Confidence;
                                    main.SetGesture(gesture.Name);
                                    sendMessage("REFRESH");
                                    Console.WriteLine("Refresh");
                                    zoomInQuantity     = 0;
                                    zoomOutQuantity    = 0;
                                    scrollUpQuantity   = 0;
                                    scrollDownQuantity = 0;
                                }
                                else if ((result.Confidence >= 0.2) && (gesture.Name.Equals(this.scrollDownGesture)))
                                {
                                    this.gestureName = this.scrollDownGesture;
                                    MaxConfidence    = result.Confidence;
                                    main.SetGesture(gesture.Name);
                                    if (scrollDownQuantity <= 5)
                                    {
                                        sendMessage("SCROLL_DOWN");
                                        scrollDownQuantity++;
                                    }
                                    zoomInQuantity   = 0;
                                    zoomOutQuantity  = 0;
                                    scrollUpQuantity = 0;

                                    Console.WriteLine("ScrollDown");
                                }
                                else if ((result.Confidence >= 0.4) && (gesture.Name.Equals(this.scrollUpGesture)))
                                {
                                    this.gestureName = this.scrollUpGesture;
                                    MaxConfidence    = result.Confidence;
                                    main.SetGesture(gesture.Name);
                                    if (scrollUpQuantity <= 5)
                                    {
                                        sendMessage("SCROLL_UP");
                                        scrollUpQuantity++;
                                    }
                                    zoomInQuantity     = 0;
                                    zoomOutQuantity    = 0;
                                    scrollDownQuantity = 0;

                                    Console.WriteLine("ScrollUp");
                                }

                                if (MaxConfidenceTimer != null)
                                {
                                    MaxConfidenceTimer.Stop();
                                }

                                MaxConfidenceTimer           = new Timer(2 * 1000);
                                MaxConfidenceTimer.Elapsed  += ResetConfidence;
                                MaxConfidenceTimer.AutoReset = false;
                                MaxConfidenceTimer.Enabled   = true;
                            }
                        }
                    }
                }
            }
        }
예제 #13
0
        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);
                }
            }
        }
예제 #14
0
        private void vgbFramereader_FrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e)
        {
            //VisualGestureBuilderFrameReference frameReference = e.FrameReference.AcquireFrame;
            using (VisualGestureBuilderFrame frame = e.FrameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    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);

                                switch (gesture.Name)
                                {
                                case "jump":
                                    if (result != null)
                                    {
                                        if (result.Confidence > 0.3)
                                        {
                                            Thread childThread = new Thread(jump);

                                            childThread.Start();
                                        }
                                    }
                                    break;

                                case "run":
                                    if (result != null)
                                    {
                                        if (result.Confidence > 0.4)
                                        {
                                            if (this.goRight)
                                            {
                                                VirtualKeyCode keyCode = VirtualKeyCode.VK_D;
                                                inputSimulator.Keyboard.KeyDown(keyCode);     // Hold the key down

                                                Console.WriteLine(" Run Right" + result.Confidence);
                                            }
                                            else
                                            {
                                                VirtualKeyCode keyCode = VirtualKeyCode.VK_A;
                                                inputSimulator.Keyboard.KeyDown(keyCode);     // Hold the key down

                                                Console.WriteLine(" Run Left" + result.Confidence);
                                            }
                                        }
                                        else if (result.Confidence < 0.25)
                                        {
                                            if (this.goRight)
                                            {
                                                VirtualKeyCode keyCode = VirtualKeyCode.VK_D;
                                                inputSimulator.Keyboard.KeyUp(keyCode);     // Release the key

                                                Console.WriteLine(" Run Right" + result.Confidence);
                                            }
                                            else
                                            {
                                                VirtualKeyCode keyCode = VirtualKeyCode.VK_A;
                                                inputSimulator.Keyboard.KeyUp(keyCode);     // Release the key

                                                Console.WriteLine(" Run Left" + result.Confidence);
                                            }
                                        }
                                    }
                                    break;

                                case "crawl":
                                    if (result != null)
                                    {
                                        if (result.Confidence > 0.65)
                                        {
                                            Console.WriteLine("In Main: Creating the Child thread");
                                            Thread childThread = new Thread(crouch);
                                            childThread.Start();

                                            Console.WriteLine(" down " + result.Confidence);
                                        }
                                    }
                                    break;

                                case "leftArm":
                                    if (result != null)
                                    {
                                        if (result.Confidence > 0.75)
                                        {
                                            Console.WriteLine(" Left " + result.Confidence);
                                            this.goRight = false;
                                            run();
                                        }
                                    }
                                    break;

                                case "rightArm":
                                    if (result != null)
                                    {
                                        if (result.Confidence > 0.75)
                                        {
                                            Console.WriteLine(" Right " + result.Confidence);
                                            this.goRight = true;
                                            run();
                                        }
                                    }
                                    break;

                                case "shooting":
                                    if (result != null)
                                    {
                                        if (result.Confidence > 0.75)
                                        {
                                            Console.WriteLine("In Main: Creating the Child thread");
                                            Thread childThread = new Thread(shoot);
                                            childThread.Start();

                                            Console.WriteLine(" shooting " + result.Confidence);
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #15
0
    /// Handles gesture detection results arriving from the sensor for the associated body tracking Id
    private void GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e)
    {
        //Debug.Log (“GestureFrameArrived CALLED!”);
        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)
                            {
                                if ((int)(result.Confidence * 100) > 55)
                                {
                                    if (gesture.Name.Equals(landingLeftGesture))
                                    {
                                        left.Add((int)(result.Confidence * 100));
                                    }
                                    if (gesture.Name.Equals(landingRightGesture))
                                    {
                                        right.Add((int)(result.Confidence * 100));
                                    }
                                    if (gesture.Name.Equals(landing))
                                    {
                                        land.Add((int)(result.Confidence * 100));
                                    }
                                    if (gesture.Name.Equals(moveUpwards))
                                    {
                                        up.Add((int)(result.Confidence * 100));
                                    }
                                    if (gesture.Name.Equals(moveDownWards))
                                    {
                                        down.Add((int)(result.Confidence * 100));
                                    }
                                    if (gesture.Name.Equals(hover))
                                    {
                                        hov.Add((int)(result.Confidence * 100));
                                    }
                                    // Fire Event
                                    //OnGesture (new EventArgs (gesture.Name, result.Confidence));
                                    Debug.Log("Detected Gesture " + gesture.Name + " with Confidence " + (int)(result.Confidence * 100));
                                }
                            }
                            else
                            {
                                Debug.Log("result is NULL@: " + result);
                            }
                        }
                    }
                }
            }
        }
    }
예제 #16
0
        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.Name.Equals(this.seatedGestureName) && gesture.GestureType == GestureType.Discrete)
                            {
                                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.Detected.Equals(true) && result.Confidence > 0.400)
                                    {
                                        //Console.Write("\nRESULT: " + result.Detected + "|" + result.Confidence);
                                        clapDetected = true;
                                    }
                                    else
                                    {
                                        clapDetected = false;
                                    }
                                }
                            }

                            if (gesture.Name.Equals(this.takeSnapName) && gesture.GestureType == GestureType.Discrete)
                            {
                                //  DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);

                                if (result != null)
                                {
                                    // need to retrain this
                                    if (result.Detected.Equals(true) && result.Confidence > 0.400)
                                    {
                                        Console.Write("\n Snap Pic Result: " + result.Detected + "|" + result.Confidence);


                                        takeSnapDetected = true;
                                        //dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 20);
                                        //dispatcherTimer.Start();
                                        //dispatcherTimer.Tick += (test, args) =>
                                        //{
                                        //    dispatcherTimer.Stop();
                                        //    takeSnapDetected = false;
                                        //};
                                    }
                                    else
                                    {
                                        takeSnapDetected = false;
                                    }
                                }
                            }

                            if (gesture.Name.Equals(this.deleteGestureName) && 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);
                                    if (result.Detected.Equals(true) && result.Confidence > 0.350)
                                    {
                                        // Console.Write("\n sliceDetected RESULT: " + result.Detected + "|" + result.Confidence);
                                        sliceDetected = true;
                                    }
                                    else
                                    {
                                        sliceDetected = false;
                                    }
                                }
                            }

                            if (gesture.Name.Equals(this.gestureMenuName) && 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);
                                    if (result.Detected.Equals(true) && result.Confidence > 0.400)
                                    {
                                        // Console.Write("\n swipe down RESULT: " + result.Detected + "|" + result.Confidence);
                                        swipedownDetected = true;
                                    }
                                    else
                                    {
                                        swipedownDetected = false;
                                    }
                                }
                            }

                            if (gesture.Name.Equals(this.menuUpName) && 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);
                                    if (result.Detected.Equals(true) && result.Confidence > 0.600)
                                    {
                                        // Console.Write("\n Swipe Up RESULT: " + result.Detected + "|" + result.Confidence);
                                        swipeUpDetected = true;
                                    }
                                    else
                                    {
                                        swipeUpDetected = false;
                                    }
                                }
                            }



                            if (gesture.Name.Equals(this.rightMenuOpenName) && 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);
                                    if (result.Detected.Equals(true) && result.Confidence > 0.600)
                                    {
                                        // Console.Write("\n rightMenuOpenName: " + result.Detected + "|" + result.Confidence);
                                        openRightDetected = true;
                                    }
                                    else
                                    {
                                        openRightDetected = false;
                                    }
                                }
                            }


                            if (gesture.Name.Equals(this.rightMenuCloseName) && 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);
                                    if (result.Detected.Equals(true) && result.Confidence > 0.800)
                                    {
                                        //Console.Write("\n Snap Pic Result: " + result.Detected + "|" + result.Confidence);
                                        closeRightDetected = true;
                                    }
                                    else
                                    {
                                        closeRightDetected = false;
                                    }
                                }
                            }

                            if (gesture.Name.Equals(this.upsideDownName) && 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);
                                    if (result.Detected.Equals(true) && result.Confidence > 0.800)
                                    {
                                        Console.Write("\n UPSIDE DOWN!!!!!!: " + result.Detected + "|" + result.Confidence);
                                        upsideDownDetected = true;
                                    }
                                    else
                                    {
                                        upsideDownDetected = false;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #17
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)
        {
            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)
                        {
                            switch (gesture.Name)
                            {
                            case "L":
                            {
                                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, "L");
                                }
                                break;
                            }

                            case "Tee":
                            {
                                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, "Tee");
                                }
                                break;
                            }

                            case "Line":
                            {
                                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, "Line");
                                }
                                break;
                            }

                            case "Z":
                            {
                                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, "Z");
                                }
                                break;
                            }

                            case "Square":
                            {
                                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, "Square");
                                }
                                break;
                            }
                            }
                        }
                    }
                }
            }
        }
예제 #18
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)
        {
            System.Diagnostics.Debug.WriteLine("1");
            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_crossing, this.num_frames_tilting, this.num_frames_pointing);
                                    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++;
                                        }
                                        if (gesture.Name == "ArmsCrossed")
                                        {
                                            this.num_frames_crossing++;
                                        }
                                        if (gesture.Name == "TiltingHead")
                                        {
                                            this.num_frames_tilting++;
                                        }
                                        if (gesture.Name == "Pointing")
                                        {
                                            this.num_frames_pointing++;
                                        }
                                    }
                                }
                            }
                        }
                        System.Diagnostics.Debug.WriteLine(this.num_gestures_detected);
                        this.GestureResultView.UpdateCurrentGestureCount(this.num_gestures_detected);
                    }
                }
            }
            // 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)
        {
            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);
                    }
                }
            }
        }
예제 #20
0
        }//dispose

        /// <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)
                {
                    IReadOnlyDictionary <Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults;
                    // get the discrete gesture results which arrived with the latest frame


                    float max = 0;
                    DiscreteGestureResult result_flower = null;
                    DiscreteGestureResult result_hover  = null;
                    DiscreteGestureResult result_stop   = null;
                    DiscreteGestureResult result_up     = null;
                    DiscreteGestureResult result_down   = null;
                    DiscreteGestureResult result_left   = null;
                    DiscreteGestureResult result_right  = null;


                    if (isFlying == false)
                    {
                        foreach (Gesture gesture in this.vgbFrameSource.Gestures)
                        {
                            if (gesture.Name.Equals("hover") && gesture.GestureType == GestureType.Discrete)
                            {
                                if (discreteResults != null)
                                {
                                    discreteResults.TryGetValue(gesture, out result_hover);
                                    if (result_hover.Confidence >= 0.3)
                                    {
                                        this.GestureResultView.Takeoff();
                                        isFlying  = true;
                                        direction = 5;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (isUnlocked == false)
                        {
                            foreach (Gesture gesture in this.vgbFrameSource.Gestures)
                            {
                                if (gesture.Name.Equals("flower") && gesture.GestureType == GestureType.Discrete)
                                {
                                    discreteResults.TryGetValue(gesture, out result_flower);
                                    if (result_flower.Confidence >= 0.8)
                                    {
                                        isUnlocked = true;
                                    }
                                }
                            }
                        }
                        else
                        {
                            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("up") && gesture.GestureType == GestureType.Discrete)
                                    {
                                        discreteResults.TryGetValue(gesture, out result_up);
                                        signal[0] = result_up.Confidence;
                                    }
                                    if (gesture.Name.Equals("left") && gesture.GestureType == GestureType.Discrete)
                                    {
                                        discreteResults.TryGetValue(gesture, out result_left);
                                        signal[1] = result_left.Confidence;
                                    }
                                    if (gesture.Name.Equals("down") && gesture.GestureType == GestureType.Discrete)
                                    {
                                        discreteResults.TryGetValue(gesture, out result_down);
                                        signal[2] = result_down.Confidence;
                                    }
                                    if (gesture.Name.Equals("right") && gesture.GestureType == GestureType.Discrete)
                                    {
                                        discreteResults.TryGetValue(gesture, out result_right);
                                        signal[3] = result_right.Confidence;
                                    }
                                    for (int i = 0; i < 4; i++)
                                    {
                                        if (Math.Abs(max) <= Math.Abs(signal[i]))
                                        {
                                            max = signal[i];
                                        }
                                    }
                                    if (Math.Abs(max) > 0.2)
                                    {
                                        if (signal[0] == max && signal[0] >= 0.5)
                                        {
                                            this.GestureResultView.UpdateGestureResult(true, true, signal[0], "↑Front↑");
                                            direction = 3;
                                        }
                                        if (signal[1] == max && signal[1] >= 0.5)
                                        {
                                            this.GestureResultView.UpdateGestureResult(true, true, signal[1], "←Left←");
                                            direction = 2;
                                        }
                                        if (signal[2] == max && signal[2] >= 0.5)
                                        {
                                            this.GestureResultView.UpdateGestureResult(true, true, signal[2], "↓Back↓");
                                            direction = 4;
                                        }
                                        if (signal[3] == max && signal[3] >= 0.5)
                                        {
                                            this.GestureResultView.UpdateGestureResult(true, true, signal[3], "→Right→");
                                            direction = 1;
                                        }
                                    }
                                    else
                                    {
                                        this.GestureResultView.UpdateGestureResult(true, true, 0.0f, "--Hover--");
                                        direction = 0;
                                    }
                                }
                            }//direction control
                            foreach (Gesture gesture in this.vgbFrameSource.Gestures)
                            {
                                if (gesture.Name.Equals("STOP") && gesture.GestureType == GestureType.Discrete)
                                {
                                    if (discreteResults != null)
                                    {
                                        discreteResults.TryGetValue(gesture, out result_stop);
                                        if (result_stop.Confidence >= 0.3)
                                        {
                                            this.GestureResultView.Stop();
                                            direction  = 6;
                                            isUnlocked = false;
                                        }
                                    }
                                }
                            }
                        } //isUnlocked true
                    }     //isFlying true
                }
            }
        }//reader gesture frame arrived
예제 #21
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)
        {
            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)
                                {
                                    bool nappingDetected    = false;
                                    bool standingDetected   = false;
                                    bool sittingDetected    = false;
                                    bool typingDetected     = false;
                                    bool writingDetected    = false;
                                    bool usingPhoneDetected = false;

                                    if (gesture.Name.Equals(nappingGestureName))
                                    {
                                        nappingDetected = result.Detected;
                                    }
                                    else if (gesture.Name.Equals(standingGestureName))
                                    {
                                        standingDetected = result.Detected;
                                    }
                                    else if (gesture.Name.Equals(seatedGestureName))
                                    {
                                        sittingDetected = result.Detected;
                                    }
                                    else if (gesture.Name.Equals(typingGestureName))
                                    {
                                        typingDetected = result.Detected;
                                    }
                                    else if (gesture.Name.Equals(writingGestureName))
                                    {
                                        writingDetected = result.Detected;
                                    }
                                    else if (gesture.Name.Equals(usingPhoneGestureName))
                                    {
                                        usingPhoneDetected = result.Detected;
                                    }

                                    // update the GestureResultView object with new gesture result values
                                    this.GestureResultView.UpdateGestureResult(true, standingDetected, sittingDetected, typingDetected, writingDetected, usingPhoneDetected, nappingDetected);
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <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");
                }
            }
        }
예제 #23
0
        /// <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)
        {
            if (RECORD_BODY_DATA == RECORD)
            {
                storebodycoordinates();
            }
            else
            {
                clearstoredframes();
            }

            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 (result != null && result.Detected == true)
                                    {
                                        //conditional statement for the detected gesture
                                        System.Diagnostics.Debug.WriteLine("starttimeVGB" + DateTime.Now.ToString("ss.fff", CultureInfo.InvariantCulture));
                                        System.Diagnostics.Debug.WriteLine(gesture.Name + " " + count.ToString());
                                        System.Diagnostics.Debug.WriteLine("endtimeVGB" + DateTime.Now.ToString("ss.fff", CultureInfo.InvariantCulture));
                                        count += 1;
                                        if (isStartGesture(gesture.Name))
                                        {
                                            DETECTED_GESTURE = gesture.Name;
                                            storebodycoordinates(); //stores current frame
                                            RECORD_BODY_DATA = RECORD;
                                        }
                                        else if (DETECTED_GESTURE != String.Empty && DETECTED_GESTURE != null)
                                        {
                                            if (isEndGestureofCurrentGesture(DETECTED_GESTURE, gesture.Name))
                                            {
                                                storebodycoordinates();
                                                string       gestureFilepath = ("D:\\DTW_files\\VGB\\" + gesture.Name + ".txt");
                                                string       gestureName     = passToDTW(gestureFilepath);
                                                GestureStore ig = new GestureStore(gestureName);
                                                DETECTED_GESTURE = String.Empty;
                                                RECORD_BODY_DATA = EMPTY;
                                            }
                                        }
                                    }
                                }

                                catch (Exception ex)
                                {
                                    // do nothing
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <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++;
                }
            }
        }
    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);
    }
예제 #26
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)
        {
            //check if this gesture detector was paused by its body(when a body leaves view, it gets paused)
            if (!IsPaused)
            {
                VisualGestureBuilderFrameReference frameReference = e.FrameReference;
                using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame())
                {
                    if (frame != null)
                    {
                        // get the discrete gesture results which arrived with the latest frame
                        IReadOnlyDictionary <string, float> discreteResults;
                        IReadOnlyDictionary <string, float> continuousResults;

                        if (bufferCount < bufferSize)
                        {
                            IReadOnlyDictionary <string, float> tempDict = gestureHandler.getLinkedDiscreteResults(frame.DiscreteGestureResults);
                            if (tempDict != null)
                            {
                                discreteResultsBuffer[bufferCount]   = tempDict;
                                continuousResultsBuffer[bufferCount] = gestureHandler.getLinkedContinuousResult(frame.ContinuousGestureResults);
                                bufferCount++;
                            }
                        }
                        else //if (discreteResults != null)//Check for dicrete results only, as a gesture always has some discrete data.
                        {
                            bufferCount       = 0;
                            discreteResults   = getAverageDiscreteResults();
                            continuousResults = getAverageContinuousResults();

                            Dictionary <string, float> confidenceReturnList = new Dictionary <string, float>(); //multiple gestures can have the same confidence, use name as key
                            Dictionary <string, float> progressReturnList   = new Dictionary <string, float>(); //multiple gestures can have the same confidence, use name as key

                            List <PseudoGesture> linkedGestureList = gestureHandler.linkGestures(this.vgbFrameSource);
                            //iterate trough the entire list of possible (pseudo) gestures
                            foreach (PseudoGesture gesture in linkedGestureList)
                            {
                                if (gesture.gestureType == GestureType.Discrete)
                                {
                                    float DiscreteResult = discreteResults[gesture.gestureName];
                                    if (DiscreteResult != 0)
                                    {
                                        // update the GestureResultView object with new gesture result values
                                        this.eventHandler.raiseGestureResultEvent((long)this.TrackingId, gesture.gestureName, DiscreteResult);

                                        //we want a list that consists of max 3 gestures:

                                        if (confidenceReturnList.Count < 3)//add 3 entries before checking which is bigger
                                        {
                                            confidenceReturnList.Add(gesture.gestureName, DiscreteResult);
                                        }
                                        else
                                        {
                                            bool bigger = false;//set if this gesture has a higher confidence then any of the stored gestures
                                            foreach (KeyValuePair <string, float> entry in confidenceReturnList)
                                            {
                                                if (DiscreteResult <= entry.Value)
                                                {
                                                    bigger = true;
                                                }
                                            }
                                            if (bigger)
                                            {
                                                //add the gesture that has a bigger confidence level to the list
                                                confidenceReturnList.Add(gesture.gestureName, DiscreteResult);

                                                //but now the list has 4 entries instead of 3, the following code removes the entry with lowest confidence:

                                                float lowest = 0;//set to be the same as the gesture with lowest confidence
                                                foreach (KeyValuePair <string, float> entry in confidenceReturnList)
                                                {
                                                    if (entry.Value < lowest || lowest == 0)
                                                    {
                                                        lowest = entry.Value;
                                                    }
                                                }
                                                string keyToRemove = "";//find the gesture name of the gesture with the lowest confidence
                                                foreach (KeyValuePair <string, float> entry in confidenceReturnList)
                                                {
                                                    if (entry.Value == lowest)
                                                    {
                                                        keyToRemove = entry.Key;
                                                        //in case multiple gestures have the same confidence (many probably have 0 as confidence)
                                                        //only remove the first found entry that has the lowest confidence so break, making the list size back to 3
                                                        break;
                                                    }
                                                }
                                                if (!keyToRemove.Equals(""))//redundant, but check if we found the gesture that has the lowest confidence
                                                {
                                                    confidenceReturnList.Remove(keyToRemove);
                                                }
                                            } //END OF --- if(bigger)
                                        }     //END OF --- if (confidenceList.Count < 3) else
                                    }         //END OF --- if(Discreteresults != null)
                                }             //END OF --- if (gesture.GestureType == GestureType.Discrete)

                                if (gesture.gestureType == GestureType.Continuous && continuousResults != null)
                                {
                                    float ContinuousResult = continuousResults[gesture.gestureName];
                                    if (ContinuousResult != 0)
                                    {
                                        // update the GestureResultView object with new gesture result values
                                        this.eventHandler.raiseGestureContinuousResultEvent((long)this.TrackingId, gesture.gestureName, ContinuousResult);

                                        //we want a list that consists of max 3 gestures:

                                        if (progressReturnList.Count < 3)//add 3 entries before checking which is bigger
                                        {
                                            progressReturnList.Add(gesture.gestureName, ContinuousResult);
                                        }
                                        else
                                        {
                                            bool bigger = false;//set if this gesture has a higher progress then any of the stored gestures
                                            foreach (KeyValuePair <string, float> entry in progressReturnList)
                                            {
                                                if (ContinuousResult <= entry.Value)
                                                {
                                                    bigger = true;
                                                }
                                            }
                                            if (bigger)
                                            {
                                                //add the gesture that has a bigger progress level to the list
                                                progressReturnList.Add(gesture.gestureName, ContinuousResult);

                                                //but now the list has 4 entries instead of 3, the following code removes the entry with lowest progress:

                                                float lowest = 0;//set to be the same as the gesture with lowest progress
                                                foreach (KeyValuePair <string, float> entry in progressReturnList)
                                                {
                                                    if (entry.Value < lowest || lowest == 0)
                                                    {
                                                        lowest = entry.Value;
                                                    }
                                                }
                                                string keyToRemove = "";//find the gesture name of the gesture with the lowest progress
                                                foreach (KeyValuePair <string, float> entry in progressReturnList)
                                                {
                                                    if (entry.Value == lowest)
                                                    {
                                                        keyToRemove = entry.Key;
                                                        //in case multiple gestures have the same progress (many probably have 0 as progress)
                                                        //only remove the first found entry that has the lowest confidence so break, making the list size back to 3
                                                        break;
                                                    }
                                                }
                                                if (!keyToRemove.Equals(""))//redundant, but check if we found the gesture that has the lowest progress
                                                {
                                                    progressReturnList.Remove(keyToRemove);
                                                }
                                            } //END OF --- if (bigger)
                                        }     //END OF --- if (progressList.Count < 3) else
                                    }         //END OF --- if(ContinuousResult != null)
                                }             //END OF --- if(gesture.GestureType == GestureType.Continuous && continuousResults != null)
                            }                 //END OF --- Foreach(Gesture gesture in this.vgbFrameSource.Gestures)

                            //Check if the gestures in the list actually have some value
                            //No need to check for values in the progressList as discretegestures will always be fired first
                            bool fireGestureListEvent = false;
                            foreach (KeyValuePair <string, float> entry in confidenceReturnList)
                            {
                                if (entry.Value != 0)
                                {
                                    fireGestureListEvent = true;
                                }
                            }
                            if (fireGestureListEvent)//fire event when the gestures do have some value
                            {
                                this.eventHandler.raiseGestureListEvent(confidenceReturnList, progressReturnList, (long)TrackingId);
                            }
                        } //END OF ---  if(discreteResults != null)
                    }     //END OF --- if(frame != null)
                }
            }
        }
        /* Handles gesture detection results from the sensor for the body tracking id */
        private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e)
        {
            VisualGestureBuilderFrameReference frameReference = e.FrameReference;

            using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    /* Frame is not null , proceed */
                    /* Gest the gesutre results from the last frame that was received */
                    IReadOnlyDictionary <Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults;

                    if (discreteResults != null)
                    {
                        /* not null, proceed */
                        /* Find what gesture triggered */
                        foreach (Gesture gesture in vgbFrameSource.Gestures)
                        {
                            if (gesture.Name.Equals(gestureNames[0]) && gesture.GestureType == GestureType.Discrete)
                            {
                                /* Handle the color cycle gesture */
                                DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);

                                if (result != null)
                                {
                                    if (result.Confidence > 0.5)
                                    {
                                        uiAccess.colorCycleGesture(result.Confidence);
                                    }
                                }
                            }
                            else if (gesture.Name.Equals(gestureNames[1]) && gesture.GestureType == GestureType.Discrete)
                            {
                                /* Handle the newLightsOff gesture */
                                DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);

                                if (result != null)
                                {
                                    if (result.Confidence > 0.5)
                                    {
                                        uiAccess.lightsOffGesture(result.Confidence);
                                    }
                                }
                            }
                            else if (gesture.Name.Equals(gestureNames[2]) && gesture.GestureType == GestureType.Discrete)
                            {
                                /* Handle the newLightsOn gesture */
                                DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);

                                if (result != null)
                                {
                                    if (result.Confidence > 0.5)
                                    {
                                        uiAccess.lightsOnGesture(result.Confidence);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #28
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)
    {
        VisualGestureBuilderFrameReference frameReference  = e.FrameReference;
        VisualGestureBuilderFrameReference frameReference2 = 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.WaveLeftGestureName) && 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.WaveLeftGestureName));
                                }
                            }
                        }

                        if (gesture.Name.Equals(this.WaveRightGestureName) && 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.WaveRightGestureName));
                                }
                            }
                        }
                    }
                }
            }
        }

        using (VisualGestureBuilderFrame frame2 = frameReference.AcquireFrame())
        {
            if (frame2 != null)
            {
                // get the discrete gesture results which arrived with the latest frame
                var discreteResults = frame2.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.EnemyDetectionGestureName) && 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.EnemyDetectionGestureName));
                                }
                            }
                        }
                    }
                }
            }
        }
    }
예제 #29
0
    /// Handles gesture detection results arriving from the sensor for the associated body tracking Id
    public void GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e)
    {
        //Debug.Log("GestureFrameArrived CALLED!");
        VisualGestureBuilderFrameReference frameReference = e.FrameReference;

        using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame())
        {
            //Debug.Log("frame: "+ frame);
            if (frame != null)
            {
                //Debug.Log("frame != null");
                // get the discrete gesture results which arrived with the latest frame
                IDictionary <Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults;

                if (discreteResults != null)
                {
                    //Debug.Log("discreteResults != null");
                    foreach (Gesture gesture in _Source.Gestures)
                    {
                        if (gesture.GestureType == GestureType.Discrete)
                        {
                            //Debug.Log("G:" + gesture.Name);
                            DiscreteGestureResult result = null;
                            discreteResults.TryGetValue(gesture, out result);

                            if (result != null && (result.Confidence > 0))
                            {
                                // Fire Event
                                //OnGesture(new EventArgs(gesture.Name, result.Confidence));
                                //Debug.Log("Detected Gesture " + gesture.Name + " with Confidence " + result.Confidence);
                                //scoreValue = result.Confidence * 100;
                                //Scoreup.score += scoreValue;
                                //Debug.Log("SCORE:" + Scoreup.score);
                                //scoreValue += result.Confidence*100;
                                //text.text = "SCORE: " + scoreValue;

                                //nameGesture = gesture.Name;
                                //check = result.Confidence;

                                //////////////////////////////////////////////// INTRO SET
                                if (((getTimer.timer <= 0.831995) || (getTimer.timer > 2.197324 && getTimer.timer <= 3.370658) ||
                                     (getTimer.timer > 4.053311 && getTimer.timer <= 5.077324) || (getTimer.timer > 6.527982 && getTimer.timer <= 7.274649)) &&
                                    (gesture.Name.Equals("Intro_Left")))
                                {
                                    Debug.Log("TIME SET 1.1:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }
                                else if (((getTimer.timer > 0.831995 && getTimer.timer <= 2.197324) || (getTimer.timer > 3.370658 && getTimer.timer <= 4.053311) ||
                                          (getTimer.timer > 5.077324 && getTimer.timer <= 6.527982) || (getTimer.timer > 7.274649 && getTimer.timer <= 8.405329)) &&
                                         (gesture.Name.Equals("Intro_Right")))
                                {
                                    Debug.Log("TIME SET 1.2:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// Onigiri SET
                                else if (((getTimer.timer > 8.405329 && getTimer.timer <= 10.60265) || (getTimer.timer > 12.65066 && getTimer.timer <= 14.52798) ||
                                          (getTimer.timer > 270.784 && getTimer.timer <= 272.6187) || (getTimer.timer > 274.9653 && getTimer.timer <= 275.2)) &&
                                         (gesture.Name.Equals("Onigiri_Left")))
                                {
                                    Debug.Log("TIME SET 2.1:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }
                                else if (((getTimer.timer > 10.60265 && getTimer.timer <= 12.65066) || (getTimer.timer > 14.52798 && getTimer.timer <= 16.44798) ||
                                          (getTimer.timer > 273.0453 && getTimer.timer <= 274.496)) && (gesture.Name.Equals("Onigiri_Right")))
                                {
                                    Debug.Log("TIME SET 2.2:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// Move_on SET
                                else if (((getTimer.timer > 16.44798 && getTimer.timer <= 17.94131) || (getTimer.timer > 19.86131 && getTimer.timer <= 21.75998)) &&
                                         (gesture.Name.Equals("Move_on_Left")))
                                {
                                    Debug.Log("TIME SET 3.1:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }
                                else if (((getTimer.timer > 17.94131 && getTimer.timer <= 19.86131) || (getTimer.timer > 21.75998 && getTimer.timer <= 23.57331)) &&
                                         (gesture.Name.Equals("Move_on_Right")))
                                {
                                    Debug.Log("TIME SET 3.2:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// SLOT01
                                else if ((getTimer.timer > 25.856 && getTimer.timer <= 26.26131) && (gesture.Name.Equals("Naja")))
                                {
                                    Debug.Log("TIME SET 4:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }
                                else if ((getTimer.timer > 27.43465 && getTimer.timer <= 28.20265) || (getTimer.timer > 47.061 && getTimer.timer <= 47.744) &&
                                         (gesture.Name.Equals("Bangloey")))
                                {
                                    Debug.Log("TIME SET 5:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }
                                else if (((getTimer.timer > 29.65331 && getTimer.timer <= 30.20798) || (getTimer.timer > 129.7707 && getTimer.timer <= 130.368)) &&
                                         (gesture.Name.Equals("Nidnid")))
                                {
                                    Debug.Log("TIME SET 6:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }
                                else if (((getTimer.timer > 31.27465 && getTimer.timer <= 31.91465) || (getTimer.timer > 41.451 && getTimer.timer <= 42.027) ||
                                          (getTimer.timer > 131.84 && getTimer.timer <= 132.5013) || (getTimer.timer > 135.467 && getTimer.timer <= 136.384)) &&
                                         (gesture.Name.Equals("ChoeyMoey")))
                                {
                                    Debug.Log("TIME SET 7:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// TakeUpArm
                                else if (((getTimer.timer > 32.61866 && getTimer.timer <= 33.92) || (getTimer.timer > 48.40533 && getTimer.timer <= 49.856) ||
                                          (getTimer.timer > 137.8773 && getTimer.timer <= 138.432)) && (gesture.Name.Equals("TakeUpArm_Right")))
                                {
                                    Debug.Log("TIME SET 8.1:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }
                                else if (((getTimer.timer > 34.666 && getTimer.timer <= 35.75465) || (getTimer.timer > 50.432 && getTimer.timer <= 51.41331)) ||
                                         (getTimer.timer > 139.1147 && getTimer.timer <= 140.012) && (gesture.Name.Equals("TakeUpArm_Left")))
                                {
                                    Debug.Log("TIME SET 8.2:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// DrawBigHeart
                                else if (((getTimer.timer > 36.523 && getTimer.timer <= 38.016) || (getTimer.timer > 51.947 && getTimer.timer <= 53.76) ||
                                          (getTimer.timer > 140.48 && getTimer.timer <= 142.0373)) && (gesture.Name.Equals("DrawBigHeart")))
                                {
                                    Debug.Log("TIME SET 9:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// Yeah
                                else if (((getTimer.timer > 38.571 && getTimer.timer <= 39.829) || (getTimer.timer > 54.29331 && getTimer.timer <= 55.70132) ||
                                          (getTimer.timer > 142.4213 && getTimer.timer <= 144.1707)) && (gesture.Name.Equals("Yeah")))
                                {
                                    Debug.Log("TIME SET 10:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// TourPai
                                else if ((getTimer.timer > 43.371 && getTimer.timer <= 43.733) && (gesture.Name.Equals("TourPai")))
                                {
                                    Debug.Log("TIME SET 11:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// Tummada
                                else if ((getTimer.timer > 45.291 && getTimer.timer <= 45.89) && (gesture.Name.Equals("Tummada")))
                                {
                                    Debug.Log("TIME SET 12:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// Move_down
                                else if (((getTimer.timer > 56.68265 && getTimer.timer <= 56.87465) || (getTimer.timer > 58.091 && getTimer.timer <= 60.07465) ||
                                          (getTimer.timer > 61.376 && getTimer.timer <= 61.67465) || (getTimer.timer > 64.555 && getTimer.timer <= 64.91733) ||
                                          (getTimer.timer > 69.184 && getTimer.timer <= 69.78132) || (getTimer.timer > 144.7466 && getTimer.timer <= 145.3013) ||
                                          (getTimer.timer > 146.9866 && getTimer.timer <= 148.416) || (getTimer.timer > 149.7387 && getTimer.timer <= 150.1866) ||
                                          (getTimer.timer > 152.7253 && getTimer.timer <= 153.152) || (getTimer.timer > 157.76 && getTimer.timer <= 158.2933)) &&
                                         (gesture.Name.Equals("Move_down_Left")))
                                {
                                    Debug.Log("TIME SET 13.1:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }
                                else if (((getTimer.timer > 57.344 && getTimer.timer <= 57.68533) || (getTimer.timer > 60.75732 && getTimer.timer <= 61.184) ||
                                          (getTimer.timer > 62.08 && getTimer.timer <= 64.043) || (getTimer.timer > 65.23733 && getTimer.timer <= 65.51465) ||
                                          (getTimer.timer > 68.224 && getTimer.timer <= 68.672) || (getTimer.timer > 145.8347 && getTimer.timer <= 146.4533) ||
                                          (getTimer.timer > 148.7146 && getTimer.timer <= 149.2693) || (getTimer.timer > 150.6773 && getTimer.timer <= 152.2987) ||
                                          (getTimer.timer > 153.8133 && getTimer.timer <= 154.2827) || (getTimer.timer > 156.8 && getTimer.timer <= 157.248)) &&
                                         (gesture.Name.Equals("Move_down_Right")))
                                {
                                    Debug.Log("TIME SET 13.2:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// DownLeg
                                else if (((getTimer.timer > 65.77066 && getTimer.timer <= 67.776) || (getTimer.timer > 69.952 && getTimer.timer <= 71.403) ||
                                          (getTimer.timer > 154.752 && getTimer.timer <= 156.352) || (getTimer.timer > 158.7413 && getTimer.timer <= 160.0426)) &&
                                         (gesture.Name.Equals("Down_leg")))
                                {
                                    Debug.Log("TIME SET 14:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// LoveorNot
                                else if (((getTimer.timer > 72.91773 && getTimer.timer <= 73.49331) || (getTimer.timer > 74.667 && getTimer.timer <= 75.477) ||
                                          (getTimer.timer > 161.1946 && getTimer.timer <= 161.856) || (getTimer.timer > 163.1147 && getTimer.timer <= 163.904)) &&
                                         (gesture.Name.Equals("LoveorNot")))
                                {
                                    Debug.Log("TIME SET 15:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// Come_on
                                else if (((getTimer.timer > 75.92533 && getTimer.timer <= 77.93066) || (getTimer.timer > 164.5013 && getTimer.timer <= 166.4) ||
                                          (getTimer.timer > 223.488 && getTimer.timer <= 225.4933)) && (gesture.Name.Equals("ComeOn")))
                                {
                                    Debug.Log("TIME SET 16:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// LetsCookie
                                else if (((getTimer.timer > 78.61331 && getTimer.timer <= 79.7227) || (getTimer.timer > 167.168 && getTimer.timer <= 168.0853) ||
                                          (getTimer.timer > 226.3893 && getTimer.timer <= 227.2213)) && (gesture.Name.Equals("LetsCookie")))
                                {
                                    Debug.Log("TIME SET 17:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// Koisuru
                                else if (((getTimer.timer > 80.10664 && getTimer.timer <= 80.64) || (getTimer.timer > 167.168 && getTimer.timer <= 168.0853) ||
                                          (getTimer.timer > 168.6613 && getTimer.timer <= 169.0027) || (getTimer.timer > 184.2346 && getTimer.timer <= 184.832) ||
                                          (getTimer.timer > 227.584 && getTimer.timer <= 228.1387) || (getTimer.timer > 243.115 && getTimer.timer <= 243.5413)) &&
                                         (gesture.Name.Equals("Koisuru_Right")))
                                {
                                    Debug.Log("TIME SET 18:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }
                                else if (((getTimer.timer > 80.87465 && getTimer.timer <= 81.451) || (getTimer.timer > 95.53065 && getTimer.timer <= 96.04266) ||
                                          (getTimer.timer > 169.344 && getTimer.timer <= 169.728) || (getTimer.timer > 185.2373 && getTimer.timer <= 185.792) ||
                                          (getTimer.timer > 228.288 && getTimer.timer <= 228.9492) || (getTimer.timer > 244.0533 && getTimer.timer <= 244.6507)) &&
                                         (gesture.Name.Equals("Koisuru_Left")))
                                {
                                    Debug.Log("TIME SET 18:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// FortuneCookies
                                else if (((getTimer.timer > 81.92 && getTimer.timer <= 83.62664) || (getTimer.timer > 96.34132 && getTimer.timer <= 97.088) ||
                                          (getTimer.timer > 170.1973 && getTimer.timer <= 171.84) || (getTimer.timer > 185.8347 && getTimer.timer <= 187.5627) ||
                                          (getTimer.timer > 229.3546 && getTimer.timer <= 231.0613) || (getTimer.timer > 245.1413 && getTimer.timer <= 245.7413)) &&
                                         (gesture.Name.Equals("FurtuneCookies")))
                                {
                                    Debug.Log("TIME SET 19:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// LetsWish
                                else if (((getTimer.timer > 83.968 && getTimer.timer <= 84.459) || (getTimer.timer > 172.2453 && getTimer.timer <= 172.928) ||
                                          (getTimer.timer > 231.4026 && getTimer.timer <= 232) || (getTimer.timer > 247.3173 && getTimer.timer <= 247.744)) &&
                                         (gesture.Name.Equals("LetsWish_Right")))
                                {
                                    Debug.Log("TIME SET 20.1:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }
                                else if (((getTimer.timer > 84.62932 && getTimer.timer <= 85.119) || (getTimer.timer > 173.248 && getTimer.timer <= 173.8027) ||
                                          (getTimer.timer > 232.3627 && getTimer.timer <= 232.8746) || (getTimer.timer > 248.128 && getTimer.timer <= 248.4693)) &&
                                         (gesture.Name.Equals("LetsWish_Left")))
                                {
                                    Debug.Log("TIME SET 20.2:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// HenWing
                                else if (((getTimer.timer > 85.52533 && getTimer.timer <= 87.38132) || (getTimer.timer > 100.0746 && getTimer.timer <= 103.2107) ||
                                          (getTimer.timer > 174.2933 && getTimer.timer <= 176.864) || (getTimer.timer > 189.867 && getTimer.timer <= 191.808) ||
                                          (getTimer.timer > 233.28 && getTimer.timer <= 235.008) || (getTimer.timer > 249.0453 && getTimer.timer <= 250.752)) &&
                                         (gesture.Name.Equals("HenWing")))
                                {
                                    Debug.Log("TIME SET 21:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// HeyHey
                                else if (((getTimer.timer > 88.08533 && getTimer.timer <= 93.056) || (getTimer.timer > 104.1065 && getTimer.timer <= 108.6933) ||
                                          (getTimer.timer > 176.6613 && getTimer.timer <= 181.184) || (getTimer.timer > 192.512 && getTimer.timer <= 197.3973) ||
                                          (getTimer.timer > 235.84 && getTimer.timer <= 240.6187) || (getTimer.timer > 251.4987 && getTimer.timer <= 256.32)) &&
                                         (gesture.Name.Equals("Heyhey")))
                                {
                                    Debug.Log("TIME SET 22:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// Clap
                                else if (((getTimer.timer > 112.2987 && getTimer.timer <= 113.1307) || (getTimer.timer > 116.267 && getTimer.timer <= 116.928) ||
                                          (getTimer.timer > 120.2987 && getTimer.timer <= 120.7893) || (getTimer.timer > 200.8746 && getTimer.timer <= 201.5573) ||
                                          (getTimer.timer > 204.8213 && getTimer.timer <= 205.3546) || (getTimer.timer > 208.8746 && getTimer.timer <= 209.472) ||
                                          (getTimer.timer > 259.8613 && getTimer.timer <= 260.5226) || (getTimer.timer > 263.8933 && getTimer.timer <= 264.4266) ||
                                          (getTimer.timer > 267.776 && getTimer.timer <= 268.3733)) &&
                                         (gesture.Name.Equals("Clap")))
                                {
                                    Debug.Log("TIME SET 23:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// Up_down
                                else if (((getTimer.timer > 121.5573 && getTimer.timer <= 128.0213) || (getTimer.timer > 210.0907 && getTimer.timer <= 215.1253)) &&
                                         (gesture.Name.Equals("Up_down")))
                                {
                                    Debug.Log("TIME SET 24:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// Hairoo
                                else if ((getTimer.timer > 133.6747 && getTimer.timer <= 134.2507) && (gesture.Name.Equals("Hairoo")))
                                {
                                    Debug.Log("TIME SET 25:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// Rotate
                                else if ((getTimer.timer > 268.6507 && getTimer.timer <= 270.528) && (gesture.Name.Equals("Rotate")))
                                {
                                    Debug.Log("TIME SET 26:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// End
                                else if ((getTimer.timer > 276.8427 && getTimer.timer <= 280.448) && (gesture.Name.Equals("End")))
                                {
                                    Debug.Log("TIME SET 27:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// Point
                                else if (((getTimer.timer > 216.6187 && getTimer.timer <= 217.4507) || (getTimer.timer > 218.88 && getTimer.timer <= 219.3493)) &&
                                         (gesture.Name.Equals("Point_Left")))
                                {
                                    Debug.Log("TIME SET 28:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }
                                else if (((getTimer.timer > 215.616 && getTimer.timer <= 216.32) || (getTimer.timer > 218.048 && getTimer.timer <= 218.5173)) &&
                                         (gesture.Name.Equals("Point_Right")))
                                {
                                    Debug.Log("TIME SET 28:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                //////////////////////////////////////////////// Side
                                else if ((getTimer.timer > 220.3847 && getTimer.timer <= 223.3173) && (gesture.Name.Equals("Side")))
                                {
                                    Debug.Log("TIME SET 29:" + getTimer.timer + "Confidence :" + result.Confidence);
                                    scoreValue = result.Confidence * 100;
                                }

                                ///////// CONDITION ITEM

                                if (scoreValue >= 20)
                                {
                                    countCombo++;
                                    Debug.Log("COMBO ::::: " + countCombo);
                                    if (countCombo >= 2 && countCombo < 4)
                                    {
                                        itemx2      = true;
                                        scoreValue *= 2;
                                        //Debug.Log("COMBO COMBO COMBO COMBO COMBO AND scoreValue ="+ scoreValue);
                                    }
                                    else if (countCombo >= 4)
                                    {
                                        //Debug.Log("BONUS TIME BONUS TIME BONUS TIME BONUS TIME BONUS TIME BONUS TIME");
                                        timeTemp = getTimer.timer + 10;
                                        itemTime = true;
                                    }
                                }

                                else if (scoreValue < 10)
                                {
                                    itemx2     = false;
                                    countCombo = 0;
                                    //Debug.Log("NO COMBO NO COMBO NO COMBO NO COMBO NO COMBO");
                                }

                                else if (getTimeout.timeout == false)
                                {
                                    //Debug.Log("BONUS TIME *** BONUS TIME *** BONUS TIME *** BONUS TIME *** BONUS TIME *** BONUS TIME ");
                                }
                                else if (getTimeout.timeout == true)
                                {
                                    //Debug.Log("OUT BONUS TIME *** OUT BONUS TIME *** OUT BONUS TIME *** OUT BONUS TIME *** OUT BONUS TIME *** OUT BONUS TIME ");
                                    timeTemp = 0;
                                }

                                Scoreup.score += scoreValue;
                                scoreValue     = 0;
                                Debug.Log("SCORE:" + Scoreup.score);

                                if (getTimer.timer > 5)
                                {
                                    Debug.Log("********** 5 SECONDS**********");
                                    loadScene = true;
                                }
                            }
                            else
                            {
                                //Debug.Log("result is NULL:"+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)
        {
            if (!Kinect.Instance.Recorder.IsRecording)
            {
                return;
            }
            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)
                    {
                        Person person = Scene.Instance.Persons
                                        .FirstOrDefault(p => p.TrackingId == (long)this.TrackingId);
                        // we only have one gesture in this source object, but you can get multiple gestures
                        bool postureDetected = false;
                        foreach (Gesture gesture in this.vgbFrameSource.Gestures)
                        {
                            //Posture.Name[] postures = (Posture.Name[])Enum.GetValues(typeof(Posture.Name));
                            foreach (PostureType postureType in PostureTypeContext.db.PostureType.ToList())
                            {
                                //if (gesture.Name.Equals(this.seatedGestureName) && gesture.GestureType == GestureType.Discrete)
                                if (gesture.Name.Equals(postureType.Name) && 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);
                                        if (result.Detected && Scene.Instance != null)
                                        {
                                            //Console.WriteLine("registered posture:"+postureType.name);
                                            MicroPosture mc = new MicroPosture(
                                                postureType,
                                                Kinect.Instance.Recorder.getCurrentLocation()
                                                );

                                            person.MicroPostures.Add(mc);
                                            postureDetected = true;
                                            //Scene.Instance.persons[BodyIndex].postures.
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                        if (!postureDetected && Scene.Instance != null)
                        {
                            //Console.WriteLine("registered posture:" + PostureType.none.name);
                            person.MicroPostures.Add(new MicroPosture(PostureType.none, Kinect.Instance.Recorder.getCurrentLocation()));
                        }
                    }
                }
            }
        }