Beispiel #1
0
        private void handleMovementsWithAngles()
        {
            double currentTime = DateTime.Now.TimeOfDay.TotalMilliseconds;

            difTime = (currentTime - myVoiceAndMovementObject.timeStarted);
            armMovementsCalc.calcArmMovements();
            if (timeLastGesture == 0)
            {
                timeLastGesture = currentTime;
            }
            if (armMovementsCalc.currentGesture != PT20.ArmMovementsCalc.Gesture.nogesture)
            {
                timeLastGesture    = currentTime;
                timePreviousPauses = 0;
            }
            if (armMovementsCalc.prePreviousGesture == ArmMovementsCalc.Gesture.nogesture &&
                armMovementsCalc.currentGesture != armMovementsCalc.prePreviousGesture)
            {
                MainWindow.gestureTimes.Add(currentTime);
                //parent.videoHandler.kinectImage.Source.CloneCurrentValue();
            }
            if (armMovementsCalc.prePreviousGesture != armMovementsCalc.currentGesture &&
                armMovementsCalc.currentGesture == ArmMovementsCalc.Gesture.nogesture && MainWindow.gestureTimes.Count > 0)
            {
                MainWindow.gestureTimes.Add(currentTime);
            }



            assignPictures();

            timeBetweenGestures = currentTime - timeLastGesture + timePreviousPauses;
            if (timeBetweenGestures > 5000)
            {
                PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.HANDS_NOT_MOVING);
                pa.timeStarted = myVoiceAndMovementObject.timeStarted;
                pa.isVoiceAndMovementMistake = true;
                if (myVoiceAndMovementObject.firstImage != null)
                {
                    System.Windows.Media.ImageSource im = parent.videoHandler.kinectImage.Source;
                    //  pa.firstImage = myVoiceAndMovementObject.firstImage.CloneCurrentValue();
                    myVoiceAndMovementObject.lastImage = im.CloneCurrentValue();
                    //  pa.lastImage = im.CloneCurrentValue();
                }

                audioMovementMistakeTempList.Add(pa);
            }
        }
Beispiel #2
0
        private void handleHandMovements()
        {
            double currentTime = DateTime.Now.TimeOfDay.TotalMilliseconds;

            CameraSpacePoint handLeft  = bfpa.body.Joints[JointType.HandLeft].Position;
            CameraSpacePoint handRight = bfpa.body.Joints[JointType.HandRight].Position;
            CameraSpacePoint hipLeft   = bfpa.body.Joints[JointType.HipLeft].Position;
            CameraSpacePoint hipRight  = bfpa.body.Joints[JointType.HipRight].Position;

            double leftDistance = Math.Sqrt(
                (handLeft.X - hipLeft.X) * (handLeft.X - hipLeft.X) +
                (handLeft.Y - hipLeft.Y) * (handLeft.Y - hipLeft.Y) +
                (handLeft.Z - hipLeft.Z) * (handLeft.Z - hipLeft.Z));

            double rightDistance = Math.Sqrt(
                (handRight.X - hipRight.X) * (handRight.X - hipRight.X) +
                (handRight.Y - hipRight.Y) * (handRight.Y - hipRight.Y) +
                (handRight.Z - hipRight.Z) * (handRight.Z - hipRight.Z));

            if (myVoiceAndMovementObject.leftHandHipDistance == 0)
            {
                myVoiceAndMovementObject.leftHandHipDistance  = leftDistance;
                myVoiceAndMovementObject.rightHandHipDistance = rightDistance;
            }

            double rightMovement = Math.Abs(myVoiceAndMovementObject.rightHandHipDistance - rightDistance);
            double leftMovement  = Math.Abs(myVoiceAndMovementObject.leftHandHipDistance - leftDistance);

            myVoiceAndMovementObject.leftHandHipDistance  = leftDistance;
            myVoiceAndMovementObject.rightHandHipDistance = rightDistance;

            double currentHandMovement = rightMovement;

            if (rightMovement > leftMovement)
            {
                myVoiceAndMovementObject.totalHandMovement = myVoiceAndMovementObject.totalHandMovement + rightMovement * HandMovementFactor;
            }
            else
            {
                currentHandMovement = leftMovement;
                myVoiceAndMovementObject.totalHandMovement = myVoiceAndMovementObject.totalHandMovement + leftMovement * HandMovementFactor;
            }

            double difTime = (currentTime - myVoiceAndMovementObject.timeStarted);

            if (difTime > 0)
            {
                myVoiceAndMovementObject.averageHandMovement = myVoiceAndMovementObject.totalHandMovement / difTime;
            }

            if (myVoiceAndMovementObject.averageHandMovement < 1)//&& currentHandMovement < 0.006)
            {
                PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.HANDS_NOT_MOVING);
                pa.timeStarted = myVoiceAndMovementObject.timeStarted;
                pa.isVoiceAndMovementMistake = true;
                if (myVoiceAndMovementObject.firstImage != null)
                {
                    System.Windows.Media.ImageSource im = parent.videoHandler.kinectImage.Source;
                    //  pa.firstImage = myVoiceAndMovementObject.firstImage.CloneCurrentValue();
                    myVoiceAndMovementObject.lastImage = im.CloneCurrentValue();
                    //  pa.lastImage = im.CloneCurrentValue();
                }

                audioMovementMistakeTempList.Add(pa);
            }
            else if (difTime > 2000) //use for debugging
            {
                int aa = 0;
                aa++;
                //     myVoiceAndMovementObject.totalHandMovement = difTime + 1000;
            }
        }