本文整理汇总了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;
}
示例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;
}
示例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);
}
}
}
示例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();
}
示例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);
}