Esempio n. 1
0
    private void OnGestureDetected(object sender, GestureEventArgs e, int bodyIndex)
    {
        var isDetected = e.IsBodyTrackingIdValid && e.IsGestureDetected;

       // Debug.Log(_canvasExerciseManager.IsReady());
       // Debug.Log("GESTUREID: " + e.GestureID);

       // if ((e.GestureID == _leanRightGestureName.ToString()) && _canvasExerciseManager.GetReadyState() == "true" )
        if ((e.GestureID == gestureName.ToString() ) && _canvasExerciseManager.GetReadyState() == "true" )
        {

            GestureTextGameObject.text = "if Gesture: " + isDetected;
            ConfidenceTextGameObject.text = "if Confidence: " + e.DetectionConfidence;

            if (e.DetectionConfidence > 0.3f)
            {
               /* if (timer.IsRunning)
                {
                    if (timer.ElapsedMilliseconds >= 5000f)
                    {
                        Debug.Log("5sec");
                    }
                }
                else
                {
                    timer.Start();
                }
                var testtimer = timer.ElapsedMilliseconds * 0.001f;
                TimeTextGameObjectSW.text = timer.ElapsedMilliseconds.ToString();
                TimeTextGameObjectSW2.text = testtimer.ToString();*/

                // Fill the bar for duration
                _canvasExerciseManager.StartTime();
            }
            else
            {

                GestureTextGameObject.text = "Gesture: " + isDetected;

             /*   timer.Reset();

                var testtimer = timer.ElapsedMilliseconds * 0.001f;
                TimeTextGameObjectSW.text = timer.ElapsedMilliseconds.ToString();
                TimeTextGameObjectSW2.text = testtimer.ToString();
*/
                // Stop the timer
                _canvasExerciseManager.StopTime();

            }
        }

    }// OnGestureDetected
    private void OnGestureDetected(object sender, GestureEventArgs e, int bodyIndex)
    {
        var isDetected = e.IsBodyTrackingIdValid && e.IsGestureDetected;

       // Debug.Log(_canvasExerciseManager.IsReady());

        if ((e.GestureID == _leanRightGestureName || e.GestureID == _leanLeftGestureName) && _canvasExerciseManager.GetReadyState() == "true" )
        {

            GestureTextGameObject.text = "Gesture: " + isDetected;
            ConfidenceTextGameObject.text = "Confidence: " + e.DetectionConfidence;

            _time2 += Time.deltaTime;

            if (e.DetectionConfidence > 0.4f)
            {

                // Fill the bar for duration
                _canvasExerciseManager.StartTime();

/*
                ConfidenceTextGameObject.text += " WHOOP ";

                _time += Time.deltaTime;
                TimeTextGameObject.text = _time.ToString();

                TimeImage.fillAmount = _time/5.0f;

                if (TimeImage.fillAmount >= 1.0f)
                {
                    readyState = false;
                    //AttemptSuccess;

            */
            }
        }

    }// OnGestureDetected