Exemplo n.º 1
0
            /// <summary>
            /// Updates the face tracking information for this skeleton
            /// </summary>
            internal void OnFrameReady(KinectSensor kinectSensor, ColorImageFormat colorImageFormat, byte[] colorImage, DepthImageFormat depthImageFormat, short[] depthImage, Skeleton skeletonOfInterest)
            {
                this.skeletonTrackingState = skeletonOfInterest.TrackingState;

                if (this.skeletonTrackingState != SkeletonTrackingState.Tracked)
                {
                    // nothing to do with an untracked skeleton.
                    return;
                }

                if (this.faceTracker == null)
                {
                    try
                    {
                        this.faceTracker = new FaceTracker(kinectSensor);
                    }
                    catch (InvalidOperationException)
                    {
                        // During some shutdown scenarios the FaceTracker
                        // is unable to be instantiated.  Catch that exception
                        // and don't track a face.
                        Debug.WriteLine("AllFramesReady - creating a new FaceTracker threw an InvalidOperationException");
                        this.faceTracker = null;
                    }
                }

                if (this.faceTracker != null)
                {
                    FaceTrackFrame frame = this.faceTracker.Track(
                        colorImageFormat, colorImage, depthImageFormat, depthImage, skeletonOfInterest);

                    this.lastFaceTrackSucceeded = frame.TrackSuccessful;
                    if (this.lastFaceTrackSucceeded)
                    {
                        if (faceTriangles == null)
                        {
                            // only need to get this once.  It doesn't change.
                            faceTriangles = frame.GetTriangles();
                        }

                        if (this.DrawFaceMesh || this.DrawFeaturePoints != DrawFeaturePoint.None)
                        {
                            this.facePoints = frame.GetProjected3DShape();
                        }

                        // get the shape points array
                        if (this.DrawShapePoints)
                        {
                            // see the !!!README.txt file to add the function
                            // to your toolkit project
                            this.shapePoints = frame.GetShapePoints();
                        }
                    }

                    // draw/remove the components
                    SetFeaturePointsLocations();
                    SetShapePointsLocations();
                }
            }
Exemplo n.º 2
0
 internal String setup(FaceTrackFrame frame)
 {
     if (this.smileSetupArray.Count < SETUP_VALUES)
     {
         this.smileSetupArray.Add(frame.GetAnimationUnitCoefficients()[2]);
         this.browUpSetupArray.Add(frame.GetAnimationUnitCoefficients()[5]);
         this.browLowRSetupArray.Add(this.pointDistance(frame.GetShapePoints()[89], frame.GetShapePoints()[25]));
         this.browLowLSetupArray.Add(this.pointDistance(frame.GetShapePoints()[89], frame.GetShapePoints()[35]));
         return(".");
     }
     else
     {
         this.evaluateInitalValues();
         this.isSetupComplete = true;
         return("\r\nSetup Complete!\r\n");
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Prova i vari tipi di emozioni alla ricerca di quello esatto
 /// </summary>
 internal String analizeEmotion(FaceTrackFrame frame)
 {
     if (frame.GetAnimationUnitCoefficients()[5] > this.browUpBasicValue + BROW_UP_GAP)
     {
         return("Surprise!");
     }
     else if (frame.GetAnimationUnitCoefficients()[2] > this.smileBasicValue + SMILE_GAP)
     {
         return("Joy!");
     }
     else
     {
         double distDx = this.pointDistance(frame.GetShapePoints()[89], frame.GetShapePoints()[25]);
         double distSx = this.pointDistance(frame.GetShapePoints()[89], frame.GetShapePoints()[35]);
         if (distDx + BROW_LOW_GAP < browLowRBasicValue || distSx + BROW_LOW_GAP < browLowLBasicValue)
         {
             return("Disgust!");
         }
         else
         {
             return("No action");
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Updates the face tracking information for this skeleton
        /// </summary>
        internal void OnFrameReady(KinectSensor kinectSensor, ColorImageFormat colorImageFormat, byte[] colorImage, DepthImageFormat depthImageFormat, short[] depthImage, Skeleton skeletonOfInterest)
        {
            //elabora un frame si e due no
            if (this.rightFrameCount != 0)
            {
                if (this.rightFrameCount == 2)
                {
                    this.rightFrameCount = 0;
                }
                else //this.rightFrameCount == 1
                {
                    this.rightFrameCount++;
                }
                return;
            }
            this.rightFrameCount++;

            this.skeletonTrackingState = skeletonOfInterest.TrackingState;

            if (this.skeletonTrackingState != SkeletonTrackingState.Tracked)
            {
                // nothing to do with an untracked skeleton.
                return;
            }

            if (this.faceTracker == null)
            {
                try
                {
                    this.faceTracker = new FaceTracker(kinectSensor);
                }
                catch (InvalidOperationException)
                {
                    // During some shutdown scenarios the FaceTracker
                    // is unable to be instantiated.  Catch that exception
                    // and don't track a face.
                    System.Diagnostics.Debug.WriteLine("AllFramesReady - creating a new FaceTracker threw an InvalidOperationException");
                    this.faceTracker = null;
                }
            }

            if (this.faceTracker != null)
            {
                FaceTrackFrame frame = this.faceTracker.Track(
                    colorImageFormat, colorImage, depthImageFormat, depthImage, skeletonOfInterest);

                this.lastFaceTrackSucceeded = frame.TrackSuccessful;
                if (this.lastFaceTrackSucceeded)
                {
                    this.facePoints = frame.GetShapePoints();
                }

                if (this.pause)
                {
                    return;
                }

                if (this.analizer.IsSetupComplete)
                {
                    outputBox.AppendText(this.analizer.analizeEmotion(frame));
                    outputBox.AppendText("\r\n");
                    outputBox.ScrollToEnd();
                }
                else
                {
                    outputBox.AppendText(this.analizer.setup(frame));
                    outputBox.ScrollToEnd();
                }
            }
        }