当前位置: 首页>>代码示例>>C#>>正文


C# MediaCapture.AddVideoEffectAsync方法代码示例

本文整理汇总了C#中Windows.Media.Capture.MediaCapture.AddVideoEffectAsync方法的典型用法代码示例。如果您正苦于以下问题:C# MediaCapture.AddVideoEffectAsync方法的具体用法?C# MediaCapture.AddVideoEffectAsync怎么用?C# MediaCapture.AddVideoEffectAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.Media.Capture.MediaCapture的用法示例。


在下文中一共展示了MediaCapture.AddVideoEffectAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

		protected override async void Start()
		{
			ResourceCache.AutoReloadResources = true;
			base.Start();

			EnableGestureTapped = true;

			busyIndicatorNode = Scene.CreateChild();
			busyIndicatorNode.SetScale(0.06f);
			busyIndicatorNode.CreateComponent<BusyIndicator>();

			mediaCapture = new MediaCapture();
			await mediaCapture.InitializeAsync();
			await mediaCapture.AddVideoEffectAsync(new MrcVideoEffectDefinition(), MediaStreamType.Photo);
			await RegisterCortanaCommands(new Dictionary<string, Action> {
					{"Describe", () => CaptureAndShowResult(false)},
					{"Read this text", () => CaptureAndShowResult(true)}, 
					{"Enable preview", () => EnablePreview(true) },
					{"Disable preview", () => EnablePreview(false) },
					{"Help", Help }
				});
			
			ShowBusyIndicator(true);
			await TextToSpeech("Welcome to the Microsoft Cognitive Services sample for HoloLens and UrhoSharp.");
			ShowBusyIndicator(false);

			inited = true;
		}
开发者ID:xamarin,项目名称:urho-samples,代码行数:28,代码来源:Program.cs

示例2: ReadAsync

		/// <summary>
		/// Continuously look for a QR code
		/// NOTE: this method won't work if recording is enabled ('hey Cortana, start recording' thing).
		/// </summary>
		public static async Task<string> ReadAsync(CancellationToken token = default(CancellationToken))
		{
			var mediaCapture = new MediaCapture();
			await mediaCapture.InitializeAsync();
			await mediaCapture.AddVideoEffectAsync(new MrcVideoEffectDefinition(), MediaStreamType.Photo);

			var reader = new BarcodeReader();
			reader.Options.TryHarder = false;

			while (!token.IsCancellationRequested)
			{
				var imgFormat = ImageEncodingProperties.CreateJpeg();
				using (var ras = new InMemoryRandomAccessStream())
				{
					await mediaCapture.CapturePhotoToStreamAsync(imgFormat, ras);
					var decoder = await BitmapDecoder.CreateAsync(ras);
					using (var bmp = await decoder.GetSoftwareBitmapAsync())
					{
						Result result = await Task.Run(() =>
							{
								var source = new SoftwareBitmapLuminanceSource(bmp);
								return reader.Decode(source);
							});
						if (!string.IsNullOrEmpty(result?.Text))
							return result.Text;
					}
				}
				await Task.Delay(DelayBetweenScans);
			}
			return null;
		}
开发者ID:xamarin,项目名称:urho-samples,代码行数:35,代码来源:QrCodeReader.cs

示例3: CreateMediaCapture

        private async Task CreateMediaCapture()
        {
            mediaCapture = new MediaCapture();
            mediaCapture.Failed += mediaCapture_Failed;

            var settings = new MediaCaptureInitializationSettings()
            {
                StreamingCaptureMode = StreamingCaptureMode.Video
            };

            // Pick the back camera if one exists
            DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
            foreach (var device in devices)
            {
                // Check if the device on the requested panel supports Video Profile
                if (device.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back)
                {
                    settings.VideoDeviceId = device.Id;
                    break;
                }
            }

            try
            {
                await mediaCapture.InitializeAsync(settings);
            }
            catch (Exception)
            {
                this.progressText.Text = "No camera is available.";
                return;
            }

            captureElement.Source = mediaCapture;
            await mediaCapture.StartPreviewAsync();

            // Limit the photo capture to be a reasonable size
            var photoStreamProperties = mediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo);
            IMediaEncodingProperties mediaEncodingProperties = null;
            foreach (var photoStreamProperty in photoStreamProperties)
            {
                var videoEncodingProperties = (photoStreamProperty as VideoEncodingProperties);
                if (videoEncodingProperties != null)
                {
                    if (videoEncodingProperties.Width * videoEncodingProperties.Height <= 2048 * 1024)
                    {
                        mediaEncodingProperties = photoStreamProperty;
                    }
                }
            }

            await mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo, mediaEncodingProperties);

            if (settings.VideoDeviceId == "")
            {
                // If we didn't find a back camera, and the camera we defaulted to is a front camera, then mirror the content
                DeviceInformation info = devices[0];
                if (info.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front)
                {
                    await mediaCapture.AddVideoEffectAsync(new VideoEffectDefinition(typeof(MirrorEffect).FullName, new PropertySet()), MediaStreamType.VideoPreview);
                    await mediaCapture.AddVideoEffectAsync(new VideoEffectDefinition(typeof(MirrorEffect).FullName, new PropertySet()), MediaStreamType.Photo);
                }
            }
        }
开发者ID:austinkinross,项目名称:age-gender-guesser,代码行数:63,代码来源:MainPage.xaml.cs

示例4: OnLoaded

        private async void OnLoaded(object sender, RoutedEventArgs e)
        {
            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            m_mediaCapture = new MediaCapture();
            m_mediaCapture.Failed += mediaCapture_Failed;

            var settings = new MediaCaptureInitializationSettings()
            {
                StreamingCaptureMode = StreamingCaptureMode.Video
            };

            try
            {
                await m_mediaCapture.InitializeAsync(settings);
                
                await m_mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoPreview, GetHighestResolution());
            }
            catch (Exception)
            {               
                return;
            }

            await m_mediaCapture.AddVideoEffectAsync( new VideoEffectDefinition(typeof(ExampleVideoEffect).FullName, new PropertySet()), MediaStreamType.VideoPreview);

            m_previewVideoElement.Source = m_mediaCapture;
            await m_mediaCapture.StartPreviewAsync();
        }
开发者ID:modulexcite,项目名称:Lumia-imaging-sdk,代码行数:27,代码来源:VideoEffectView.xaml.cs

示例5: InitMediaCapture

        private async void InitMediaCapture()
        {
            mediaCapture = null;
            mediaCapture = new Windows.Media.Capture.MediaCapture();

            // for dispose purpose
            (App.Current as App).MediaCapture = mediaCapture;
            (App.Current as App).PreviewElement = capturePreview;

            await mediaCapture.InitializeAsync(captureInitSettings);

            // Add video stabilization effect during Live Capture
            //await _mediaCapture.AddEffectAsync(MediaStreamType.VideoRecord, Windows.Media.VideoEffects.VideoStabilization, null); //this will be deprecated soon
            Windows.Media.Effects.VideoEffectDefinition def = new Windows.Media.Effects.VideoEffectDefinition(Windows.Media.VideoEffects.VideoStabilization);
            await mediaCapture.AddVideoEffectAsync(def, MediaStreamType.VideoRecord);

           CreateProfile();

            // start preview

            capturePreview.Source = mediaCapture;
            
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.None;

        //// set the video Rotation
        //    _mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
        //    _mediaCapture.SetRecordRotation(VideoRotation.Clockwise90Degrees);
        }
开发者ID:ChrisKaps,项目名称:samples,代码行数:28,代码来源:MainPage.xaml.cs


注:本文中的Windows.Media.Capture.MediaCapture.AddVideoEffectAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。