コード例 #1
0
        private void skeletonOperations(AllFramesReadyEventArgs e)
        {
            Skeleton[]    skeletons;
            Skeleton      watchedSkeleton = null;
            SkeletonFrame skeletonFrame   = null;

            try
            {
                skeletonFrame = e.OpenSkeletonFrame();
                if (skeletonFrame == null)
                {
                    return;
                }
                skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                skeletonFrame.CopySkeletonDataTo(skeletons);
                watchedSkeleton = getTrackedSkeleton(skeletons, trackClosest(skeletons));

                if (watchedSkeleton != null)
                {
                    skeletonUpdated(this, new SkeletonEventArgs(watchedSkeleton));
                    // Give each tracker the updated frame.
                    if (Tools.allJointsTracked(watchedSkeleton))
                    {
                        if (Gesture.compare)
                        {
                            Gesture.testCompare(watchedSkeleton);
                        }
                        if (Posture.compare)
                        {
                            Posture.testCompare(watchedSkeleton);
                        }
                    }
                    if (Agitation.detect)
                    {
                        Agitation.testAgitation(watchedSkeleton);
                    }
                    if (HandsRaised.compare)
                    {
                        HandsRaised.testCompare(watchedSkeleton);
                    }
                    if (HandsJoined.detect)
                    {
                        HandsJoined.startDetection(watchedSkeleton);
                    }
                    if (EmotionRecognition.detect)
                    {
                        EmotionRecognition.EmotionRecognizer();
                    }
                    if (ArmsWide.compare)
                    {
                        ArmsWide.testCompare(watchedSkeleton);
                    }
                    if (ArmsCrossed.compare)
                    {
                        ArmsCrossed.testCompare(watchedSkeleton);
                    }
                    if (HandsInPocket.compare) //experimental
                    {
                        HandsInPocket.testCompare(watchedSkeleton);
                    }
                    /*Experimental movement to test the training*/
                    if (DrawingSheetAvatarViewModel.Get().isTraining)
                    {
                        if (TrainingWithAvatarViewModel.canBeInterrupted)
                        {
                            if (String.Compare(TrainingWithAvatarViewModel.AvatarGesture, "WavingTraining") == 0)
                            {
                                TrainingWithAvatarViewModel._gesture.Update(watchedSkeleton);
                            }
                            if (String.Compare(TrainingWithAvatarViewModel.AvatarGesture, "HandTraining") == 0)
                            {
                                TrainingWithAvatarViewModel._handgesture.Update(watchedSkeleton);
                            }
                            if (String.Compare(TrainingWithAvatarViewModel.AvatarGesture, "PowerTraining") == 0)
                            {
                                TrainingWithAvatarViewModel._powergesture.Update(watchedSkeleton);
                            }
                            if (String.Compare(TrainingWithAvatarViewModel.AvatarGesture, "WelcomeTraining") == 0)
                            {
                                TrainingWithAvatarViewModel._welcomegesture.Update(watchedSkeleton);
                            }
                            if (String.Compare(TrainingWithAvatarViewModel.AvatarGesture, "SaluteTraining") == 0)
                            {
                                TrainingWithAvatarViewModel._salutegesture.Update(watchedSkeleton);
                            }
                            if (String.Compare(TrainingWithAvatarViewModel.AvatarGesture, "HypeTraining") == 0)
                            {
                                TrainingWithAvatarViewModel._hypegesture.Update(watchedSkeleton);
                            }
                            if (String.Compare(TrainingWithAvatarViewModel.AvatarGesture, "FaceTraining") == 0)
                            {
                                TrainingWithAvatarViewModel._facegesture.Update(watchedSkeleton);
                            }
                        }
                    }
                    if (KinectDevice.useAutoElevation)
                    {
                        ClippedEdgesElevationChange(watchedSkeleton);
                    }
                }
            }finally{
                if (skeletonFrame != null)
                {
                    skeletonFrame.Dispose();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// define all the gestures
        /// </summary>
        private void DefineBodyGestures()
        {
            //waves
            WaveUpExt       waveUpRightExt      = new WaveUpExt(HandType.RIGHT);
            WaveUpExt       waveUpLeftExt       = new WaveUpExt(HandType.LEFT);
            WaveUpInt       waveUpLeftInt       = new WaveUpInt(HandType.LEFT);
            WaveUpInt       waveUpRightInt      = new WaveUpInt(HandType.RIGHT);
            WaveMidExt      waveMidLeftExt      = new WaveMidExt(HandType.LEFT);
            WaveMidExt      waveMidRightExt     = new WaveMidExt(HandType.RIGHT);
            WaveMidInt      waveMidLeftInt      = new WaveMidInt(HandType.LEFT);
            WaveMidInt      waveMidRightInt     = new WaveMidInt(HandType.RIGHT);
            WaveMidOpposite waveMidLeftOpposite = new WaveMidOpposite(HandType.LEFT);
            WaveUpBothExt   waveUpBothExt       = new WaveUpBothExt();
            WaveUpBothInt   waveUpBothInt       = new WaveUpBothInt();
            WaveMidBothExt  waveMidBothExt      = new WaveMidBothExt();
            WaveMidBothInt  waveMidBothInt      = new WaveMidBothInt();
            WaveMidAndUp    waveMidAndUpLeft    = new WaveMidAndUp(HandType.LEFT);
            WaveMidAndUp    waveMidAndUpRight   = new WaveMidAndUp(HandType.RIGHT);
            WaveUpOpposite  waveUpOppositeLeft  = new WaveUpOpposite(HandType.LEFT);
            //clik
            HandForward  leftHandForward   = new HandForward(HandType.LEFT);
            HandBackward leftHandBackward  = new HandBackward(HandType.LEFT);
            HandForward  rightHandForward  = new HandForward(HandType.RIGHT);
            HandBackward rightHandBackward = new HandBackward(HandType.RIGHT);
            HandMid      rightHandMid      = new HandMid(HandType.RIGHT);
            HandMid      leftHandMid       = new HandMid(HandType.LEFT);
            //standing gestures
            HandsDown              handsDown              = new HandsDown();
            HandsJoinedMid         handsJoinedMid         = new HandsJoinedMid();
            HandsInDiagonalRightUp handsInDiagonalRightUp = new HandsInDiagonalRightUp();
            ArmsCrossed            armsCrossed            = new ArmsCrossed();
            HandUp rightHandUp = new HandUp(HandType.RIGHT);
            //hands movement
            HandBehindTheOther leftHandBehinhRightHand = new HandBehindTheOther(HandType.LEFT);
            HandBehindTheOther rightHandBehindLeftHand = new HandBehindTheOther(HandType.RIGHT);
            HandAboveTheOther  leftHandAboveRightHand  = new HandAboveTheOther(HandType.LEFT);
            HandAboveTheOther  rightHandAboveLeftHand  = new HandAboveTheOther(HandType.RIGHT);
            //vertical waves
            HandUp   leftHandUp   = new HandUp(HandType.LEFT);
            HandDown leftHandDown = new HandDown(HandType.LEFT);
            //others
            HandExtToBody leftHandExtToBody = new HandExtToBody(HandType.LEFT);



            //WAVE_UP_LEFT_INT_TO_EXT
            BodyGestureSegment[] waveUpLeftIntToExt = new BodyGestureSegment[3] {
                waveUpLeftInt, waveUpLeftExt, waveUpLeftInt
            };
            this.AddGesture(BodyGestureName.WAVE_UP_LEFT_INT_EXT_INT, waveUpLeftIntToExt);

            //LEFT_HAND:MOVING FORWARD AND BACKWARD
            BodyGestureSegment[] leftHandClickGesture = new BodyGestureSegment[2] {
                rightHandForward, rightHandBackward
            };
            this.AddGesture(BodyGestureName.CLICK, leftHandClickGesture);

            BodyGestureSegment[] rightHandClickGesture = new BodyGestureSegment[2] {
                leftHandForward, leftHandBackward
            };
            this.AddGesture(BodyGestureName.CLICK, rightHandClickGesture);

            //LEFT_HAND:MOVING FORWARD
            BodyGestureSegment[] leftHandForwardGesture = new BodyGestureSegment[1] {
                leftHandForward
            };
            this.AddGesture(BodyGestureName.LEFT_HAND_FORWARD, leftHandForwardGesture);

            //LEFT_HAND:MOVING  BACKWARD
            BodyGestureSegment[] leftHandBackwardGesture = new BodyGestureSegment[1] {
                leftHandBackward
            };
            this.AddGesture(BodyGestureName.LEFT_HAND_BACKWARD, leftHandBackwardGesture);

            //RIGHT_HAND:MOVING FORWARD
            BodyGestureSegment[] rightHandForwardGesture = new BodyGestureSegment[1] {
                rightHandForward
            };
            this.AddGesture(BodyGestureName.RIGHT_HAND_FORWARD, rightHandForwardGesture);

            //RIGHT_HAND:MOVING  BACKWARD
            BodyGestureSegment[] rightHandBackwardGesture = new BodyGestureSegment[1] {
                rightHandBackward
            };
            this.AddGesture(BodyGestureName.RIGHT_HAND_BACKWARD, rightHandBackwardGesture);

            //LEFT_HAND:WAVE_UP_INT_EXT_INT_EXT
            BodyGestureSegment[] waveUPLeftIntExtIntExt = new BodyGestureSegment[4] {
                waveUpLeftInt, waveUpLeftExt, waveUpLeftInt, waveUpLeftExt
            };
            this.AddGesture(BodyGestureName.WAVE_UP_LEFT_INT_EXT_INT_EXT, waveUPLeftIntExtIntExt);

            //BOTH_HANDS:WAVE_MID_EXT_TO_INT_JOINED_MID
            BodyGestureSegment[] waveMIDLeftandRightExtToInt = new BodyGestureSegment[3] {
                waveMidBothExt, waveMidBothInt, handsJoinedMid
            };
            this.AddGesture(BodyGestureName.MENU, waveMIDLeftandRightExtToInt);

            //LEFT_HAND:WAVE_MID_INT_EXT_TO_INT
            BodyGestureSegment[] waveMidLeftExtToInt = new BodyGestureSegment[3] {
                waveMidLeftInt, waveMidLeftExt, waveMidLeftInt
            };
            this.AddGesture(BodyGestureName.WAVE_MID_LEFT_INT_EXT_INT, waveMidLeftExtToInt);

            //LEFT_HAND:WAVE_MID_INT_OPPOSITE_INT
            BodyGestureSegment[] waveMidLeftIntToOpposite = new BodyGestureSegment[3] {
                waveMidLeftInt, waveMidLeftOpposite, waveMidLeftInt
            };
            this.AddGesture(BodyGestureName.WAVE_MID_LEFT_INT_OPPOSITE_INT, waveMidLeftIntToOpposite);

            //RIGHT_HAND:WAVE_MID_INT_EXT_TO_INT
            BodyGestureSegment[] waveMidRightExtToInt = new BodyGestureSegment[3] {
                waveMidRightInt, waveMidRightExt, waveMidRightInt
            };
            this.AddGesture(BodyGestureName.WAVE_MID_RIGHT_INT_EXT_INT, waveMidRightExtToInt);


            //LEFT_HAND:WAVE_MID_INT_TO_EXT
            BodyGestureSegment[] waveMidleftIntToExt = new BodyGestureSegment[1] {
                waveMidLeftExt
            };
            this.AddGesture(BodyGestureName.WAVE_MID_LEFT_EXT, waveMidleftIntToExt);

            //LEFT_HAND:WAVE_MID_INT_TO_EXT
            BodyGestureSegment[] waveMidleftIntToOpposite = new BodyGestureSegment[1] {
                waveMidLeftOpposite
            };
            this.AddGesture(BodyGestureName.WAVE_MID_LEFT_OPPOSITE, waveMidleftIntToOpposite);

            //LEFT_HAND:VERTICAL_WAVE_MID_DOWN
            BodyGestureSegment[] waveMidleftMidToDown = new BodyGestureSegment[3] {
                waveMidRightExt, leftHandExtToBody, leftHandDown
            };
            this.AddGesture(BodyGestureName.VERTICAL_WAVE_LEFT_DOWN, waveMidleftMidToDown);

            //LEFT_HAND:VERTICAL_WAVE_MID_UP
            BodyGestureSegment[] waveMidleftMidToUp = new BodyGestureSegment[3] {
                waveMidRightExt, leftHandExtToBody, leftHandUp
            };
            this.AddGesture(BodyGestureName.VERTICAL_WAVE_LEFT_UP, waveMidleftMidToUp);


            //IDLE
            BodyGestureSegment[] handsDownGesture = new BodyGestureSegment[1] {
                handsDown
            };
            this.AddGesture(BodyGestureName.HANDS_DOWN, handsDownGesture);

            //ROLLING HANDS FORWARD
            //BodyGestureSegment[] rollingHandsLeftForward = new BodyGestureSegment[2] { leftHandBehinhRightHand, rightHandBehindLeftHand };
            //this.AddGesture(BodyGestureName.ROLLINGS_HANDS_LEFT_FORWARD, rollingHandsLeftForward);

            //BodyGestureSegment[] rollingHandsRightForward = new BodyGestureSegment[2] { rightHandBehindLeftHand, leftHandBehinhRightHand };
            //this.AddGesture(BodyGestureName.ROLLINGS_HANDS_RIGHT_FORWARD, rollingHandsRightForward);

            //VERTICAL WAVES
            BodyGestureSegment[] verticalWaveLeftMidUpMid = new BodyGestureSegment[5] {
                leftHandExtToBody, leftHandMid, leftHandUp, leftHandMid, leftHandExtToBody
            };
            this.AddGesture(BodyGestureName.VERTICAL_WAVE_LEFT_MID_UP_MID, verticalWaveLeftMidUpMid);

            BodyGestureSegment[] verticalWaveLeftMidDownMid = new BodyGestureSegment[5] {
                leftHandExtToBody, leftHandMid, leftHandDown, leftHandMid, leftHandExtToBody
            };
            this.AddGesture(BodyGestureName.VERTICAL_WAVE_LEFT_MID_DOWN_MID, verticalWaveLeftMidDownMid);

            //DIAGONALS
            BodyGestureSegment[] diagonalRightUpIntToExt = new BodyGestureSegment[2] {
                handsJoinedMid, handsInDiagonalRightUp
            };
            this.AddGesture(BodyGestureName.DIAGONAL_RIGHT_UP_INT_EXT, diagonalRightUpIntToExt);

            BodyGestureSegment[] diagonalRightUpExtToInt = new BodyGestureSegment[2] {
                handsInDiagonalRightUp, handsJoinedMid
            };
            this.AddGesture(BodyGestureName.DIAGONAL_RIGHT_UP_EXT_INT, diagonalRightUpExtToInt);

            //ARMS_CROSSED
            BodyGestureSegment[] armsCrossedGesture = new BodyGestureSegment[1] {
                armsCrossed
            };
            this.AddGesture(BodyGestureName.ARMSCROSSED, armsCrossedGesture);

            //LEFT_HAND:WAVE_UP_LEFT_OPPOSITE_TO_EXT
            BodyGestureSegment[] waveUpLeftOppositeToExt = new BodyGestureSegment[2] {
                waveUpOppositeLeft, waveUpLeftExt
            };
            this.AddGesture(BodyGestureName.WAVE_UP_LEFT_OPPOSITE_TO_EXT, waveUpLeftOppositeToExt);

            //RIGHT_HAND:UP
            BodyGestureSegment[] rightHandUpGesture = new BodyGestureSegment[1] {
                rightHandUp
            };
            this.AddGesture(BodyGestureName.RIGHT_HAND_UP, rightHandUpGesture);


            LogHelper.logInput("BodyGestures defined", LogHelper.logType.INFO, this);
        }
コード例 #3
0
        /// <summary>
        /// Function called when the user clicked on the OK button of the window
        /// </summary>
        private void ShowResults()
        {
            if ((isLoad && NbRecording > 0) || IsAtLeastOneCheckBoxIsChecked(choiceResultView.stkPanel))
            {
                choiceResultView.Close();
                List <bool> lbool = new List <bool>();
                lbool.Add(choiceResultView.chkAgitationHips.IsChecked.HasValue && choiceResultView.chkAgitationHips.IsChecked.Value); // this is a way to convert a bool? to a bool
                lbool.Add(choiceResultView.chkAgitationLHand.IsChecked.HasValue && choiceResultView.chkAgitationLHand.IsChecked.Value);
                lbool.Add(choiceResultView.chkAgitationLKnee.IsChecked.HasValue && choiceResultView.chkAgitationLKnee.IsChecked.Value);
                lbool.Add(choiceResultView.chkAgitationLShoulder.IsChecked.HasValue && choiceResultView.chkAgitationLShoulder.IsChecked.Value);
                lbool.Add(choiceResultView.chkAgitationRHand.IsChecked.HasValue && choiceResultView.chkAgitationRHand.IsChecked.Value);
                lbool.Add(choiceResultView.chkAgitationRKnee.IsChecked.HasValue && choiceResultView.chkAgitationRKnee.IsChecked.Value);
                lbool.Add(choiceResultView.chkAgitationRShoulder.IsChecked.HasValue && choiceResultView.chkAgitationRShoulder.IsChecked.Value);
                lbool.Add(choiceResultView.chkHandsJoined.IsChecked.HasValue && choiceResultView.chkHandsJoined.IsChecked.Value);
                lbool.Add(choiceResultView.chkArmsCrossed.IsChecked.HasValue && choiceResultView.chkArmsCrossed.IsChecked.Value);
                lbool.Add(choiceResultView.chkEmotion.IsChecked.HasValue && choiceResultView.chkEmotion.IsChecked.Value);
                lbool.Add(choiceResultView.chkLookDirec.IsChecked.HasValue && choiceResultView.chkLookDirec.IsChecked.Value);
                lbool.Add(choiceResultView.chkNumberSyllables.IsChecked.HasValue && choiceResultView.chkNumberSyllables.IsChecked.Value);
                var results = new ResultsView(lbool);
                if (isLoad) //if the windowis called after a user click on the "Open charts analysis"
                {
                    List <string> listpathdate = new List <string>();

                    if (lastRecord) // to know if the "Last Record" choice is selected in the comboBox
                    {
                        listpathdate.Add(listpath.ElementAt(0));
                    }
                    else
                    {
                        foreach (string s in listpath)
                        {
                            DateTime date = Tools.getDateFromPath(s);
                            if (date.CompareTo(maxDate) <= 0 && date.CompareTo(minDate) >= 0) // we compare the minimum date and the maximum date
                            {
                                listpathdate.Add(s);
                            }
                        }
                    }
                    ((ResultsViewModel)results.DataContext).loadManyCharts(listpathdate); // we called the function to load files
                }
                else //if the window is called after the user clicked on the button "Display my results"
                {
                    ((ResultsViewModel)results.DataContext).getAgitationStatistics(Agitation.getAgitationStats());
                    List <IGraph> temp = new List <IGraph>();
                    temp.AddRange(HandsJoined.getHandStatistics());
                    temp.AddRange(ArmsCrossed.getArmsStatistics());
                    ((ResultsViewModel)results.DataContext).getArmsMotion(temp); //temp is a union between HandsJoined.getHandStatistics() and ArmsCrossed.getArmsStatistics()
                    if (TrackingSideToolViewModel.get().FaceTracking)
                    {
                        List <IGraph> listGraphFace = new List <IGraph>();
                        listGraphFace.AddRange(EmotionRecognition.getEmotionsStatistics());
                        listGraphFace.AddRange(lookingDirection.getLookingStatistics());

                        ((ResultsViewModel)results.DataContext).getFaceStatistics(listGraphFace);
                    }
                    if (TrackingSideToolViewModel.get().SpeedRate)
                    {
                        List <IGraph> listGraphVoice = new List <IGraph>();
                        listGraphVoice.AddRange(AudioProvider.getVoiceStatistics());
                        ((ResultsViewModel)results.DataContext).getVoiceStatistics(listGraphVoice);
                    }
                }
                ((ResultsViewModel)results.DataContext).addResultsPartToView();
                results.Show();
            }
        }