示例#1
0
        /// <summary>
        ///  Disables and removes the video stabilization effect, and unregisters the event handler for the EnabledChanged event of the effect
        /// </summary>
        /// <returns></returns>
        private async Task CleanUpVideoStabilizationEffectAsync()
        {
            // No work to be done if there is no effect
            if (_videoStabilizationEffect == null)
            {
                return;
            }

            // Disable the effect
            _videoStabilizationEffect.Enabled = false;

            _videoStabilizationEffect.EnabledChanged -= VideoStabilizationEffect_EnabledChanged;

            // Remove the effect (see ClearEffectsAsync method to remove all effects from a stream)
            await _mediaCapture.RemoveEffectAsync(_videoStabilizationEffect);

            Debug.WriteLine("VS effect removed from pipeline");

            // If backed up settings (stream properties and encoding profile) exist, restore them and clear the backups
            if (_inputPropertiesBackup != null)
            {
                await _mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoRecord, _inputPropertiesBackup);

                _inputPropertiesBackup = null;
            }

            if (_outputPropertiesBackup != null)
            {
                _encodingProfile.Video  = _outputPropertiesBackup;
                _outputPropertiesBackup = null;
            }

            // Clear the member variable that held the effect instance
            _videoStabilizationEffect = null;
        }
示例#2
0
        private async Task CleanupCameraAsync()
        {
            if (mediaCapture != null)
            {
                if (isPreviewing)
                {
                    await mediaCapture.StopPreviewAsync();

                    if (videoEffect != null)
                    {
                        await mediaCapture.RemoveEffectAsync(videoEffect);
                    }
                }

                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    PreviewControl.Source = null;
                    if (displayRequest != null)
                    {
                        displayRequest.RequestRelease();
                    }

                    mediaCapture.Dispose();
                    mediaCapture = null;
                });
            }
        }
示例#3
0
        /// <summary>
        /// Disables and removes the scene analysis effect, and unregisters the event handler for the SceneAnalyzed event of the effect
        /// </summary>
        /// <returns></returns>
        private async Task CleanSceneAnalysisEffectAsync()
        {
            // Disable detection and unsubscribe from the events
            _sceneAnalysisEffect.HighDynamicRangeAnalyzer.Enabled = false;
            _sceneAnalysisEffect.SceneAnalyzed -= SceneAnalysisEffect_SceneAnalyzed;

            // Remove the effect from the pipeline (see ClearEffectsAsync method to remove all effects from a given stream)
            await _mediaCapture.RemoveEffectAsync(_sceneAnalysisEffect);

            Debug.WriteLine("SA effect removed from pipeline");

            // Clear the member variable that held the effect instance
            _sceneAnalysisEffect = null;
        }
        /// <summary>
        ///  Disables and removes the face detection effect, and unregisters the event handler for face detection
        /// </summary>
        /// <returns></returns>
        private async Task CleanUpFaceDetectionEffectAsync()
        {
            // Disable detection
            _faceDetectionEffect.Enabled = false;

            // Unregister the event handler
            _faceDetectionEffect.FaceDetected -= FaceDetectionEffect_FaceDetected;

            // Remove the effect (see ClearEffectsAsync method to remove all effects from a stream)
            await _mediaCapture.RemoveEffectAsync(_faceDetectionEffect);

            // Clear the member variable that held the effect instance
            _faceDetectionEffect = null;
        }
示例#5
0
        private async Task CleanUp()
        {
            if (_faceDetectionEffect != null)
            {
                _faceDetectionEffect.FaceDetected -= FaceDetectionEffect_FaceDetected;
                _faceDetectionEffect.Enabled       = false;

                await _mediaCapture?.RemoveEffectAsync(_faceDetectionEffect);

                _faceDetectionEffect = null;
            }

            if (_orientationSensor != null)
            {
                _orientationSensor.OrientationChanged -= OrientationSensor_OrientationChanged;
            }

            if (_displayInformation != null)
            {
                _displayInformation.OrientationChanged -= DisplayInformation_OrientationChanged;
            }

            if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
            {
                HardwareButtons.CameraPressed -= HardwareButtons_CameraPressed;
            }

            if (_mediaCapture != null)
            {
                if (_mediaCapture.CameraStreamState == Windows.Media.Devices.CameraStreamState.Streaming)
                {
                    await _mediaCapture.StopPreviewAsync();
                }

                _mediaCapture.Dispose();
                _mediaCapture = null;
            }

            _initialized = false;
        }