public ExerciseValidator(Exercise exercise, IBodyDrawer exampleBodyDrawer)
        {
            // Set default state
            state   = ValidatorState.NotStarted;
            frame   = 0;
            current = 0;

            this.exercise  = exercise;
            exerciseScores = new List <ExerciseScore>();

            this.exampleBodyDrawer = exampleBodyDrawer;
        }
Esempio n. 2
0
        public void GetSensor()
        {
            sensor = KinectSensor.GetDefault();
            sensor.Open();

            Int32Rect colorFrameSize = new Int32Rect()
            {
                Width = sensor.ColorFrameSource.FrameDescription.Width,
                Height = sensor.ColorFrameSource.FrameDescription.Height
            };
            bodyDrawers = new IBodyDrawer[brushes.Length];

            for (int i = 0; i < brushes.Length; i++)
            {
                bodyDrawers[i] = bodyDrawerFactory();
                bodyDrawers[i].Brush = brushes[i];
                bodyDrawers[i].Init(sensor.CoordinateMapper, colorFrameSize);
            }
        }
        void Start()
        {
            TimerText.text          = "";
            TimerCountdownText.text = "";

            _sensor = KinectSensor.GetDefault();

            if (_sensor != null)
            {
                _reader = _sensor.BodyFrameSource.OpenReader();

                if (!_sensor.IsOpen)
                {
                    _sensor.Open();
                }
            }


            // Create bodyDrawer and body from prefab
            GameObject body = (GameObject)Instantiate(Resources.Load("Prefabs/Body"));

            bodyDrawer = new BodyDrawer(body);

            // Get singleton session instance
            homeRevalSession = HomeRevalSession.Instance;

            // Temp for creating recording
            if (homeRevalSession.CurrentRecording == null)
            {
                homeRevalSession.CurrentRecording = new Exercise
                {
                    StartDate   = DateTime.Today,
                    EndDate     = DateTime.Today.AddDays(20),
                    Amount      = 5,
                    Name        = "test",
                    Description = "test desc"
                };
            }

            StartCoroutine(HandGesture());
        }
Esempio n. 4
0
        void Start()
        {
            TimerText.text          = "";
            TimerCountdownText.text = "";

            _sensor = KinectSensor.GetDefault();

            if (_sensor != null)
            {
                _reader = _sensor.BodyFrameSource.OpenReader();

                if (!_sensor.IsOpen)
                {
                    _sensor.Open();
                }
            }

            StartCoroutine(HandGesture());

            state = PractiseState.KinectPaused;

            // Create bodyDrawer and body from prefab
            GameObject body = (GameObject)Instantiate(Resources.Load("Prefabs/Body"));

            bodyDrawer = new BodyDrawer(body);

            // Create bodyDrawer for exercise example
            GameObject bodyRed = (GameObject)Instantiate(Resources.Load("Prefabs/BodyRed"));

            exampleBodyDrawer = new BodyDrawer(bodyRed);

            // Get singleton session instance
            hrs = HomeRevalSession.Instance;

            StartCoroutine(requestService.Get("/exercise/" + hrs.Exercises[hrs.currentExerciseIdx].Id,
                                              success =>
            {
                // Decompress response and create ExerciseRecording
                Debug.Log(success);
                JObject response = JObject.Parse(success);

                Debug.Log("Recording: " + response.GetValue("recording").ToString());

                string exerciseRecordingJson = Gzip.DeCompress(Convert.FromBase64String(response.GetValue("recording").ToString()));

                ExerciseRecording exerciseRecording = JsonConvert.DeserializeObject <ExerciseRecording>(exerciseRecordingJson);

                jsonExercise = new Exercise
                {
                    Id                = Int32.Parse(response.GetValue("id").ToString()),
                    Amount            = hrs.Exercises[hrs.currentExerciseIdx].Amount,
                    ExerciseRecording = exerciseRecording,
                    Description       = response.GetValue("description").ToString(),
                    Name              = response.GetValue("name").ToString()
                };

                exerciseService.StartNewExercise(jsonExercise, exampleBodyDrawer);

                exerciseResultRecording = new List <ConvertedBody>();
                exerciseResultScores    = new List <ExerciseScore>();
            },
                                              error =>
            {
                Debug.Log(error);
            }
                                              ));
            Debug.Log(hrs.Exercises[hrs.currentExerciseIdx].PlanningId);
            hrs.currentPlanningId = hrs.Exercises[hrs.currentExerciseIdx].PlanningId;

            // Maak exercise object met recording opgehaald vanuit database

            // Set exercise for service temp
            //string json = File.ReadAllText(@"C:\Users\Stefan\Documents\exercise.json");
            //Exercise jsonExercise = JsonConvert.DeserializeObject<Exercise>(json);
        }
 public void StartNewExercise(Exercise exercise, IBodyDrawer exampleBodyDrawer)
 {
     exerciseValidator = new ExerciseValidator(exercise, exampleBodyDrawer);
 }