Esempio n. 1
0
        public void getLeftHandUnderHip()
        {
            double x1 = body.Joints[JointType.HandLeft].Position.X * Math.Cos(shouldersAngle);
            double z1 = body.Joints[JointType.HandLeft].Position.Z * Math.Sin(shouldersAngle);

            double x2 = body.Joints[JointType.HipLeft].Position.X * Math.Cos(shouldersAngle);
            double z2 = body.Joints[JointType.HipLeft].Position.Z * Math.Sin(shouldersAngle);

            double x3 = (body.Joints[JointType.HipLeft].Position.X - body.Joints[JointType.HipRight].Position.X)
                        * (body.Joints[JointType.HipLeft].Position.X - body.Joints[JointType.HipRight].Position.X);
            double z3 = (body.Joints[JointType.HipLeft].Position.Z - body.Joints[JointType.HipRight].Position.Z)
                        * (body.Joints[JointType.HipLeft].Position.Z - body.Joints[JointType.HipRight].Position.Z);
            double length1 = Math.Sqrt(x3 + z3);

            if (body.Joints[JointType.HandTipLeft].Position.Y < body.Joints[JointType.HipLeft].Position.Y &&
                x2 - z2 < x1 - z1 + length1 * .01)
            {
                leftHandUnderHips = true;
                bodyPosture       = Posture.bad;
                PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.LEFTHANDUNDERHIP);
                currentMistakes.Add(pa);
            }
            else
            {
                leftHandUnderHips = false;
            }
        }
Esempio n. 2
0
        private void handleVolume()
        {
            double currentTime = DateTime.Now.TimeOfDay.TotalMilliseconds;

            if (myVoiceAndMovementObject.minVolume == 0)
            {
                myVoiceAndMovementObject.minVolume = apa.averageVolume;
                myVoiceAndMovementObject.maxVolume = apa.averageVolume;
            }
            if (apa.averageVolume < myVoiceAndMovementObject.minVolume)
            {
                myVoiceAndMovementObject.minVolume = apa.averageVolume;
            }
            if (apa.averageVolume > myVoiceAndMovementObject.maxVolume)
            {
                myVoiceAndMovementObject.maxVolume = apa.averageVolume;
            }
            if (apa.averageVolume > apa.ThresholdIsSpeakingLoud)
            {
                LowVolume = null;
                if (highVolume == null)
                {
                    highVolume = new PresentationAction(PresentationAction.MistakeType.HIGH_VOLUME);
                    highVolume.isVoiceAndMovementMistake = true;
                }
                if (currentTime - highVolume.timeStarted > TIME_TO_CONSIDER_ACTION)
                {
                    audioMovementMistakeTempList.Add(highVolume);
                }
            }
            else if (apa.averageVolume < apa.ThresholdIsSpeakingSoft)
            {
                highVolume = null;

                if (LowVolume == null)
                {
                    LowVolume = new PresentationAction(PresentationAction.MistakeType.LOW_VOLUME);
                    LowVolume.isVoiceAndMovementMistake = true;
                }
                if (currentTime - LowVolume.timeStarted > TIME_TO_CONSIDER_ACTION)
                {
                    audioMovementMistakeTempList.Add(LowVolume);
                }
            }
            else
            {
                highVolume = null;
                LowVolume  = null;
            }
            if (currentTime - myVoiceAndMovementObject.timeStarted > 3000 &&
                myVoiceAndMovementObject.maxVolume - myVoiceAndMovementObject.minVolume < 0.001)
            {
                PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.LOW_MODULATION);
                {
                    pa.timeStarted = myVoiceAndMovementObject.timeStarted;
                    pa.isVoiceAndMovementMistake = true;
                    audioMovementMistakeTempList.Add(pa);
                }
            }
        }
Esempio n. 3
0
        public void getHunch()
        {
            double x1 = body.Joints[JointType.Head].Position.X * Math.Sin(shouldersAngle);
            double z1 = body.Joints[JointType.Head].Position.Z * Math.Cos(shouldersAngle);

            double x2 = body.Joints[JointType.SpineShoulder].Position.X * Math.Sin(shouldersAngle);
            double z2 = body.Joints[JointType.SpineShoulder].Position.Z * Math.Cos(shouldersAngle);



            double distanceShoulders = Math.Sqrt((body.Joints[JointType.ShoulderRight].Position.X - body.Joints[JointType.ShoulderLeft].Position.X) *
                                                 (body.Joints[JointType.ShoulderRight].Position.X - body.Joints[JointType.ShoulderLeft].Position.X) +
                                                 (body.Joints[JointType.ShoulderRight].Position.Z - body.Joints[JointType.ShoulderLeft].Position.Z) *
                                                 (body.Joints[JointType.ShoulderRight].Position.Z - body.Joints[JointType.ShoulderLeft].Position.Z));



            if (-x1 + z1 < -x2 + z2 - distanceShoulders * 0.05)
            {
                hunch       = true;
                bodyPosture = Posture.bad;
                PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.HUNCHBACK);
                currentMistakes.Add(pa);
            }
            else
            {
                hunch = false;
            }
        }
Esempio n. 4
0
        public PresentationAction Clone()
        {
            PresentationAction pa = new PresentationAction();

            pa.averageHandMovement = this.averageHandMovement;
            pa.averageVolume       = this.averageVolume;
            if (firstImage != null)
            {
                pa.firstImage = this.firstImage.Clone();
            }

            pa.hasFinished = this.hasFinished;
            pa.interrupt   = this.interrupt;
            pa.isMistake   = this.isMistake;
            pa.isSpeaking  = this.isSpeaking;
            pa.isVoiceAndMovementMistake = this.isVoiceAndMovementMistake;
            if (lastImage != null)
            {
                pa.lastImage = this.lastImage.Clone();
            }

            pa.maxVolume         = this.maxVolume;
            pa.message           = this.message;
            pa.minVolume         = this.minVolume;
            pa.myGoodie          = this.myGoodie;
            pa.myMistake         = this.myMistake;
            pa.timeFinished      = this.timeFinished;
            pa.totalHandMovement = this.totalHandMovement;

            return(pa);
        }
Esempio n. 5
0
        private void handleFace()
        {
            double currentTime = DateTime.Now.TimeOfDay.TotalMilliseconds;

            if (ffpa.smilingTemp == true)
            {
                lastSmile = currentTime;
                putSmile();
            }
            else
            {
                removeSmile();
            }
            if (currentTime - lastSmile > ThresholdSmile)
            {
                PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.SERIOUS);
                pa.timeStarted = currentTime;// -lastSmile - ThresholdSmile;
                pa.isVoiceAndMovementMistake = true;
                pa.firstImage = parent.videoHandler.kinectImage.Source.CloneCurrentValue();
                if (currentTime - lastSmile > ThresholdSmile + TIME_TO_CONSIDER_INTERRUPTION)
                {
                    pa.interrupt = true;
                }
                audioMovementMistakeTempList.Add(pa);
            }
        }
Esempio n. 6
0
        public void getResetPosture()
        {
            bool useAngles = false;

            if (useAngles)
            {
            }
            else
            {
                float x = Math.Abs(body.Joints[JointType.HandTipRight].Position.X - body.Joints[JointType.HandTipLeft].Position.X);
                float y = Math.Abs(body.Joints[JointType.HandTipRight].Position.Y - body.Joints[JointType.HandTipLeft].Position.Y);
                float z = Math.Abs(body.Joints[JointType.HandTipRight].Position.Z - body.Joints[JointType.HandTipLeft].Position.Z);

                if (armsCrossed == false && legsCrossed == false &&
                    rightHandBehindBack == false && leftHandBehindBack == false &&
                    rightLean == false && leftLean == false && hunch == false &&
                    body.HandRightState != HandState.Closed && body.HandLeftState != HandState.Closed &&
                    leftArmClosePosture == false && rightArmClosePosture == false &&
                    x < 0.04 &&
                    y < 0.04 &&
                    z < 0.04)
                {
                    resetPosture = true;
                    bodyPosture  = Posture.good;
                    PresentationAction pa = new PresentationAction(PresentationAction.GoodType.RESETPOSTURE);
                    currentGoodies.Add(pa);
                }
                else
                {
                    resetPosture = false;
                }
            }
        }
Esempio n. 7
0
        private void putSmile()
        {
            PresentationAction pa = new PresentationAction(PresentationAction.GoodType.SMILE);

            pa.timeStarted = DateTime.Now.TimeOfDay.TotalMilliseconds;
            if (GoodiesList.Count == 0)
            {
                GoodiesList.Add(pa); //TODO make it work for more goodies
            }
        }
Esempio n. 8
0
 private void handleHmmm()
 {
     if (apa.foundHmmm == true)
     {
         PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.HMMMM);
         pa.timeStarted = myVoiceAndMovementObject.timeStarted;
         pa.isVoiceAndMovementMistake = true;
         audioMovementMistakeTempList.Add(pa);
     }
 }
Esempio n. 9
0
        private bool checkTimeToPutInterruption(PresentationAction fa)
        {
            bool   result      = false;
            double currentTime = DateTime.Now.TimeOfDay.TotalMilliseconds;

            if (currentTime - fa.timeStarted > TIME_TO_CONSIDER_INTERRUPTION)
            {
                result = true;
            }
            return(result);
        }
Esempio n. 10
0
        private bool findMistakeInMistakeList(PresentationAction fb)
        {
            bool found = false;

            foreach (PresentationAction fa in mistakeList)
            {
                if (fb.myMistake == fa.myMistake)
                {
                    found = true;
                    break;
                }
            }
            return(found);
        }
Esempio n. 11
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);
            }
        }
Esempio n. 12
0
        public JudgementMaker(MainWindow parent)
        {
            this.parent = parent;
            myVoiceAndMovementObject = new PresentationAction();
            periodicMovements        = new PeriodicMovements();

            armMovementsCalc             = new ArmMovementsCalc(this);
            tempMistakeList              = new ArrayList();
            mistakeList                  = new ArrayList();
            GoodiesList                  = new ArrayList();
            voiceAndMovementsList        = new ArrayList();
            audioMovementMistakeTempList = new ArrayList();
            bodyMistakes                 = new ArrayList();
            lastSmile            = DateTime.Now.TimeOfDay.TotalMilliseconds;
            lastPostureImageTime = DateTime.Now.TimeOfDay.TotalMilliseconds;
        }
Esempio n. 13
0
        private void handleTimeSpeaking()
        {
            double currentTime = DateTime.Now.TimeOfDay.TotalMilliseconds;

            if (currentTime - myVoiceAndMovementObject.timeStarted > apa.ThresholdIsSpeakingLongTime)
            {
                PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.LONG_TALK);
                pa.timeStarted = myVoiceAndMovementObject.timeStarted;
                pa.isVoiceAndMovementMistake = true;
                if (currentTime - myVoiceAndMovementObject.timeStarted > apa.ThresholdIsSpeakingVeryLongTime)
                {
                    pa.interrupt = true;
                }

                audioMovementMistakeTempList.Add(pa);
            }
        }
Esempio n. 14
0
        public void handlePauses()
        {
            double currentTime = DateTime.Now.TimeOfDay.TotalMilliseconds;

            timePausing = currentTime - myVoiceAndMovementObject.timeStarted;
            if (timePausing > apa.ThresholdIsLongPauseTime)
            {
                PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.LONG_PAUSE);
                pa.timeStarted = myVoiceAndMovementObject.timeStarted;
                pa.isVoiceAndMovementMistake = true;
                if (currentTime - myVoiceAndMovementObject.timeStarted > apa.ThresholdIsVeryLongPauseTime)
                {
                    pa.interrupt = true;
                }

                audioMovementMistakeTempList.Add(pa);
            }
        }
Esempio n. 15
0
        public void getArmsCrossed()
        {
            bool useAngles = false;

            if (useAngles)
            {
                double x1 = body.Joints[JointType.HandRight].Position.X * Math.Cos(shouldersAngle);
                double z1 = body.Joints[JointType.HandRight].Position.Z * Math.Sin(shouldersAngle);

                double x2 = body.Joints[JointType.HandLeft].Position.X * Math.Cos(shouldersAngle);
                double z2 = body.Joints[JointType.HandLeft].Position.Z * Math.Sin(shouldersAngle);


                if (x1 - z1 < x2 - z2)
                {
                    armsCrossed = true;
                    bodyPosture = Posture.bad;

                    PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.ARMSCROSSED);
                    currentMistakes.Add(pa);
                }
                else
                {
                    armsCrossed = false;
                }
            }
            else
            {
                if (body.Joints[JointType.HandRight].Position.X + 0.1 < body.Joints[JointType.HandLeft].Position.X)
                {
                    armsCrossed = true;
                    bodyPosture = Posture.bad;
                    PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.ARMSCROSSED);
                    currentMistakes.Add(pa);
                }
                else
                {
                    armsCrossed = false;
                }
            }
        }
Esempio n. 16
0
        public void getLegsCrossed()
        {
            bool useAngles = false;

            if (useAngles)
            {
            }
            else
            {
                if (body.Joints[JointType.AnkleRight].Position.X < body.Joints[JointType.AnkleLeft].Position.X)
                {
                    legsCrossed = true;
                    bodyPosture = Posture.bad;
                    PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.LEGSCROSSED);
                    currentMistakes.Add(pa);
                }
                else
                {
                    legsCrossed = false;
                }
            }
        }
Esempio n. 17
0
        void getLeftLean()
        {
            bool useAngles = false;

            if (useAngles)
            {
            }
            else
            {
                if (body.Joints[JointType.ShoulderLeft].Position.X > body.Joints[JointType.HipLeft].Position.X)
                {
                    leftLean    = true;
                    bodyPosture = Posture.bad;
                    PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.LEFTLEAN);
                    currentMistakes.Add(pa);
                }
                else
                {
                    leftLean = false;
                }
            }
        }
Esempio n. 18
0
        public void getLeftHandBehindBack()
        {
            bool useAngles = false;

            if (useAngles)
            {
                double x1 = body.Joints[JointType.HandLeft].Position.X * Math.Sin(shouldersAngle);
                double z1 = body.Joints[JointType.HandLeft].Position.Z * Math.Cos(shouldersAngle);

                double x2 = body.Joints[JointType.SpineMid].Position.X * Math.Sin(shouldersAngle);
                double z2 = body.Joints[JointType.SpineMid].Position.Z * Math.Cos(shouldersAngle);

                if (-x1 + z1 < -x2 + z2)
                {
                    leftHandBehindBack = true;
                    bodyPosture        = Posture.bad;
                    PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.LEFTHANDBEHINDBACK);
                    currentMistakes.Add(pa);
                }
                else
                {
                    leftHandBehindBack = false;
                }
            }
            else
            {
                if (body.Joints[JointType.HandLeft].Position.Z > body.Joints[JointType.SpineMid].Position.Z)
                {
                    leftHandBehindBack = true;
                    bodyPosture        = Posture.bad;
                    PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.LEFTHANDBEHINDBACK);
                    currentMistakes.Add(pa);
                }
                else
                {
                    leftHandBehindBack = false;
                }
            }
        }
Esempio n. 19
0
        void getRightLean()
        {
            bool useAngles = false;

            if (useAngles)
            {
            }
            else
            {
                if (body.Joints[JointType.ShoulderRight].Position.X < body.Joints[JointType.HipRight].Position.X)
                {
                    rightLean   = true;
                    bodyPosture = Posture.bad;
                    PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.RIGHTLEAN);
                    currentMistakes.Add(pa);
                }
                else
                {
                    rightLean = false;
                }
            }
        }
Esempio n. 20
0
        private void searchMistakes()
        {
            addBodyMistakes();
            deleteBodyMistakes();
            findMistakesInVoiceAndMovement();
            deleteVoiceAndMovementsMistakes();
            mistakeList = new ArrayList(bodyMistakes);
            mistakeList.AddRange(audioMovementMistakeTempList);

            if (bfpa.body != null)
            {
                if (periodicMovements.checPeriodicMovements(bfpa.body))
                {
                    PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.DANCING);
                    //  pa.interrupt = true;
                    // periodicMov = true;
                    mistakeList.Insert(0, pa);
                }
            }



            //todo add mistakes together
        }
Esempio n. 21
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;
            }
        }