Exemple #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _sensor = KinectSensor.GetDefault();

            if (_sensor != null)
            {
                _sensor.Open();

                _width  = _sensor.ColorFrameSource.FrameDescription.Width;
                _height = _sensor.ColorFrameSource.FrameDescription.Height;
                _pixels = new byte[_width * _height * 4];
                _bitmap = new WriteableBitmap(_width, _height, 96.0, 96.0, PixelFormats.Bgra32, null);

                this.faceManager = new FaceManager(_sensor);

                DatabaseManager.LoadFaceInfo();

                this.drawingEngine = new DrawingEngine(_sensor, canvasDraw);

                _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Body |
                                                             FrameSourceTypes.Color |
                                                             FrameSourceTypes.Depth |
                                                             FrameSourceTypes.Infrared);
                _reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived;

                camera.Source = _bitmap;
            }
        }
Exemple #2
0
        public void DrawLatestFaceResults(FaceManager manager, WriteableBitmap lastBitmap)
        {
            int counter = 0;

            for (int i = 0; i < manager.bodyCount; i++)
            {
                if (manager.faceTrackers[i].Reader != null)
                {
                    HighDefinitionFaceFrame frame = manager.faceTrackers[i].Reader.AcquireLatestFrame();

                    if (frame != null && frame.FaceModel != null && frame.IsFaceTracked)
                    {
                        DrawFaceBoundingBox(frame, manager.faceTrackers[i], faceColors[i]);
                        DrawFaceBodyInfo(manager.faceTrackers[i], faceColors[i], counter);

                        if (!manager.faceTrackers[i].ScreenshotTaken && manager.faceTrackers[i].CollectionCompleted)
                        {
                            if (lastBitmap != null)
                            {
                                ScreenshotFace(manager.faceTrackers[i], lastBitmap);
                            }
                        }

                        counter++;
                    }
                }
            }
        }