Exemplo n.º 1
0
 public void addNormalData(FaceNormal f)
 {
     _normal_list.AddLast(f);
     while (f.time.Subtract(_normal_list.First().time) > span)
     {
         _normal_list.RemoveFirst();
     }
 }
Exemplo n.º 2
0
        void NormalFaceReader_FrameArrived(object sender, FaceFrameArrivedEventArgs e)
        {
            using (var frame = e.FrameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    // 4) Get the face frame result
                    FaceFrameResult result = frame.FaceFrameResult;

                    if (result != null)
                    {
                        // 5) Do magic!
                        var f = new FaceNormal(result);
                        _faceData.addNormalData(f);
                        infoNormal.Text  = f.dump_str();
                        infoNormal.Text += _faceData.dump_str();

                        // Get the face points, mapped in the color space.

                        var eyeLeft  = result.FacePointsInColorSpace[FacePointType.EyeLeft];
                        var eyeRight = result.FacePointsInColorSpace[FacePointType.EyeRight];

                        // Position the canvas UI elements
                        Canvas.SetLeft(ellipseEyeLeft, eyeLeft.X - ellipseEyeLeft.Width / 2.0);
                        Canvas.SetTop(ellipseEyeLeft, eyeLeft.Y - ellipseEyeLeft.Height / 2.0);

                        Canvas.SetLeft(ellipseEyeRight, eyeRight.X - ellipseEyeRight.Width / 2.0);
                        Canvas.SetTop(ellipseEyeRight, eyeRight.Y - ellipseEyeRight.Height / 2.0);

                        // Display or hide the ellipses
                        if (f.eyeLeftClosed == DetectionResult.Yes || f.eyeLeftClosed == DetectionResult.Maybe)
                        {
                            ellipseEyeLeft.Visibility = Visibility.Collapsed;
                        }
                        else
                        {
                            ellipseEyeLeft.Visibility = Visibility.Visible;
                        }

                        if (f.eyeRightClosed == DetectionResult.Yes || f.eyeRightClosed == DetectionResult.Maybe)
                        {
                            ellipseEyeRight.Visibility = Visibility.Collapsed;
                        }
                        else
                        {
                            ellipseEyeRight.Visibility = Visibility.Visible;
                        }
                    }
                }
            }
        }