internal async Task <ExampleMediaFrameReader> CreateFrameReaderAsync_Impl()
        {
            MediaFrameReader faceDetectionFrameReader = null;

            if (InitializationSettings.FaceDetectionAffinity == ExampleMediaCaptureFaceDetectionAffinity.FrameReader)
            {
                faceDetectionFrameReader = await PreviewMediaCapture.CreateFrameReaderAsync(PreviewMediaCapture.FrameSources[ExclusiveRgbSourceInfo.Id]);
            }

            var frameReader = new ExampleMediaFrameReader(
                new Dictionary <MediaFrameSourceKind, MediaFrameReader> {
#if USE_INFRARED
                { MediaFrameSourceKind.Infrared, await ExclusiveMediaCapture.CreateFrameReaderAsync(FrameSources[ExclusiveIrSourceInfo.Id]) },
#else
                { MediaFrameSourceKind.Infrared, await PreviewMediaCapture.CreateFrameReaderAsync(PreviewMediaCapture.FrameSources[ExclusiveRgbSourceInfo.Id]) },
#endif
                { MediaFrameSourceKind.Color, await PreviewMediaCapture.CreateFrameReaderAsync(PreviewMediaCapture.FrameSources[ExclusiveRgbSourceInfo.Id]) },
            },
                faceDetectionFrameReader,
                PreviewFaceDetectionEffect,
                InitializationSettings.FrameCorrelationTimeSpan);

            frameReader.FaceDetected += FrameReader_FaceDetected;
            return(frameReader);
        }
        private async Task EnablePreviewFaceDetectionAsync(FaceDetectionMode faceDetectionMode)
        {
            PreviewFaceDetectionEffect = await PreviewMediaCapture.AddVideoEffectAsync(new FaceDetectionEffectDefinition()
            {
                DetectionMode = faceDetectionMode,
                SynchronousDetectionEnabled = false,
            }, ExclusiveRgbSourceInfo.MediaStreamType) as FaceDetectionEffect;

            PreviewFaceDetectionEffect.FaceDetected += PreviewFaceDetectionEffect_FaceDetected;
        }
 internal async Task StopPreviewAsync_Impl()
 {
     await PreviewMediaCapture.StopPreviewAsync();
 }