Exemple #1
0
        private async void MediaCapture_FaceDetected(ExampleMediaCapture sender, FaceDetectedEventArgs args)
        {
            // This event is raised even when no faces are present, the argument must be inspected

            if (args.ResultFrame.DetectedFaces.Any() && FrameReader != null)
            {
                if (PreviewOpacity == 0.0)
                {
                    await FrameReader.StartAsync();

                    PreviewOpacity = 1.0;
                }

                // Reset the countdown to turning off camera
                FrameReaderStopTrigger.Stop();
                FrameReaderStopTrigger.Start();
            }

            UpdateSystemRelativeTime(args.ResultFrame.SystemRelativeTime);
        }
Exemple #2
0
        private async Task StopOperationAsync()
        {
            MediaCapture.FaceDetected -= MediaCapture_FaceDetected;
            FrameReader.FrameArrived  -= FrameReader_FrameArrived;

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                CaptureElement.Source = null;
            });

            await MediaCapture.StopPreviewAsync();

            await FrameReader.StopAsync();

            FrameCollection.Dispose();
            ColorFrameEpochs.Clear();
            IlluminatedInfraredFrameEpochs.Clear();
            NonIlluminatedInfraredFrameEpochs.Clear();

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, DispatcherTimer.Stop);

            FrameReaderStopTrigger.Stop();
        }