/// <summary> /// Creates an instance of the AdvancedPhotoCapture, configures it to capture HDR images, and registers for its events /// </summary> /// <returns></returns> private async Task EnableHdrAsync() { // No work to be done if there already is an AdvancedCapture if (_advancedCapture != null) { return; } // Explicitly choose HDR mode var settings = new AdvancedPhotoCaptureSettings { Mode = AdvancedPhotoMode.Hdr }; // Configure the mode _mediaCapture.VideoDeviceController.AdvancedPhotoControl.Configure(settings); // Prepare for an advanced capture _advancedCapture = await _mediaCapture.PrepareAdvancedPhotoCaptureAsync(ImageEncodingProperties.CreateJpeg()); Debug.WriteLine("Enabled HDR mode"); // Register for events published by the AdvancedCapture _advancedCapture.AllPhotosCaptured += AdvancedCapture_AllPhotosCaptured; _advancedCapture.OptionalReferencePhotoCaptured += AdvancedCapture_OptionalReferencePhotoCaptured; }
/// <summary> /// Cleans up the instance of the AdvancedCapture /// </summary> /// <returns></returns> private async Task DisableHdrAsync() { // No work to be done if there is no AdvancedCapture if (_advancedCapture == null) { return; } await _advancedCapture.FinishAsync(); _advancedCapture = null; Debug.WriteLine("Disabled HDR mode"); }
/// <summary> /// This event will be raised only on devices that support returning a reference photo, which is a normal exposure of the scene /// without HDR, also referred to as "EV0". /// </summary> /// <param name="sender">The object raising this event.</param> /// <param name="args">The event data.</param> private async void AdvancedCapture_OptionalReferencePhotoCaptured(AdvancedPhotoCapture sender, OptionalReferencePhotoCapturedEventArgs args) { // Retrieve the context (i.e. what capture does this belong to?) var context = args.Context as AdvancedCaptureContext; Debug.WriteLine("AdvancedCapture_OptionalReferencePhotoCaptured for {0}", context.CaptureFileName); // Remove "_HDR" from the name of the capture to create the name of the reference var referenceName = context.CaptureFileName.Replace("_HDR", ""); using (var frame = args.Frame) { await ReencodeAndSavePhotoAsync(frame, referenceName, context.CaptureOrientation); } }
/// <summary> /// Cleans up the instance of the AdvancedCapture /// </summary> /// <returns></returns> private async Task DisableAdvancedCaptureAsync() { // No work to be done if there is no AdvancedCapture if (_advancedCapture == null) { return; } await _advancedCapture.FinishAsync(); _advancedCapture = null; // Reset the Advanced Capture Mode index _advancedCaptureMode = -1; Debug.WriteLine("Disabled Advanced Capture"); }
/// <summary> /// This event will be raised only on devices that support returning a reference photo, which is a normal exposure of the scene /// without HDR, also referred to as "EV0". /// </summary> /// <param name="sender">The object raising this event.</param> /// <param name="args">The event data.</param> private async void AdvancedCapture_OptionalReferencePhotoCaptured(AdvancedPhotoCapture sender, OptionalReferencePhotoCapturedEventArgs args) { // Retrieve the context (i.e. what capture does this belong to?) var context = args.Context as AdvancedCaptureContext; // Remove "_HDR" from the name of the capture to create the name of the reference photo (this is the non-HDR capture) var referenceName = context.CaptureFileName.Replace("_HDR", ""); var file = await _captureFolder.CreateFileAsync(referenceName, CreationCollisionOption.GenerateUniqueName); Debug.WriteLine("AdvancedCapture_OptionalReferencePhotoCaptured for " + context.CaptureFileName + ". Saving to " + file.Path); using (var frame = args.Frame) { await ReencodeAndSavePhotoAsync(frame, file, context.CaptureOrientation); } }
/// <summary> /// This event will be raised only on devices that support returning a reference photo, which is a normal exposure of the scene /// without processing, also referred to as "EV0". /// </summary> /// <param name="sender">The object raising this event.</param> /// <param name="args">The event data.</param> private async void AdvancedCapture_OptionalReferencePhotoCaptured(AdvancedPhotoCapture sender, OptionalReferencePhotoCapturedEventArgs args) { // Retrieve the context (i.e. the information about the capture this event belongs to) var context = args.Context as AdvancedCaptureContext; // Add "_Reference" at the end of the filename to create when saving the reference photo var referenceName = context.CaptureFileName.Replace(".jpg", "_Reference.jpg"); // Hold a reference to the frame before the async file creation operation so it's not cleaned up before ReencodeAndSavePhotoAsync using (var frame = args.Frame) { var file = await _captureFolder.CreateFileAsync(referenceName, CreationCollisionOption.GenerateUniqueName); Debug.WriteLine("AdvancedCapture_OptionalReferencePhotoCaptured for " + context.CaptureFileName + ". Saving to " + file.Path); await ReencodeAndSavePhotoAsync(frame, file, context.CaptureOrientation); } }
/// <summary> /// Creates an instance of the AdvancedPhotoCapture and registers for its events /// </summary> /// <returns></returns> private async Task EnableAdvancedCaptureAsync() { // No work to be done if there already is an AdvancedCapture instance if (_advancedCapture != null) { return; } // Configure one of the modes in the control CycleAdvancedCaptureMode(); // Prepare for an Advanced Capture _advancedCapture = await _mediaCapture.PrepareAdvancedPhotoCaptureAsync(ImageEncodingProperties.CreateJpeg()); Debug.WriteLine("Enabled Advanced Capture"); // Register for events published by the AdvancedCapture _advancedCapture.AllPhotosCaptured += AdvancedCapture_AllPhotosCaptured; _advancedCapture.OptionalReferencePhotoCaptured += AdvancedCapture_OptionalReferencePhotoCaptured; }
private async Task InitializeForLowLight() { _lowLightSupported = _mediaCapture.VideoDeviceController.AdvancedPhotoControl.SupportedModes.Contains(Windows.Media.Devices.AdvancedPhotoMode.LowLight); _mediaCapture.VideoDeviceController.DesiredOptimization = MediaCaptureOptimization.Quality; if (_lowLightSupported) { // Choose LowLight mode var settings = new AdvancedPhotoCaptureSettings { Mode = AdvancedPhotoMode.LowLight }; _mediaCapture.VideoDeviceController.AdvancedPhotoControl.Configure(settings); // Prepare for an advanced capture _advancedCapture = await _mediaCapture.PrepareAdvancedPhotoCaptureAsync(ImageEncodingProperties.CreateUncompressed(MediaPixelFormat.Nv12)); } }
/// <summary> /// This event will be raised when the capturing part of the HDR process is completed, and at this point the camera is technically ready /// to capture again while HDR fusion occurs. /// </summary> /// <param name="sender">The object raising this event.</param> /// <param name="args">The event data.</param> private void AdvancedCapture_AllPhotosCaptured(AdvancedPhotoCapture sender, object args) { Debug.WriteLine("AdvancedCapture_AllPhotosCaptured"); }
/// <summary> /// Cleans up the instance of the AdvancedCapture /// </summary> /// <returns></returns> private async Task DisableHdrAsync() { // No work to be done if there is no AdvancedCapture if (_advancedCapture == null) return; await _advancedCapture.FinishAsync(); _advancedCapture = null; Debug.WriteLine("Disabled HDR mode"); }
/// <summary> /// Cleans up the instance of the AdvancedCapture /// </summary> /// <returns></returns> private async Task DisableAdvancedCaptureAsync() { // No work to be done if there is no AdvancedCapture if (_advancedCapture == null) return; await _advancedCapture.FinishAsync(); _advancedCapture = null; // Reset the Advanced Capture Mode index _advancedCaptureMode = -1; Debug.WriteLine("Disabled Advanced Capture"); }
/// <summary> /// Creates an instance of the AdvancedPhotoCapture and registers for its events /// </summary> /// <returns></returns> private async Task EnableAdvancedCaptureAsync() { // No work to be done if there already is an AdvancedCapture instance if (_advancedCapture != null) return; // Configure one of the modes in the control CycleAdvancedCaptureMode(); // Prepare for an Advanced Capture _advancedCapture = await _mediaCapture.PrepareAdvancedPhotoCaptureAsync(ImageEncodingProperties.CreateJpeg()); Debug.WriteLine("Enabled Advanced Capture"); // Register for events published by the AdvancedCapture _advancedCapture.AllPhotosCaptured += AdvancedCapture_AllPhotosCaptured; _advancedCapture.OptionalReferencePhotoCaptured += AdvancedCapture_OptionalReferencePhotoCaptured; }
/// <summary> /// Creates an instance of the AdvancedPhotoCapture, configures it to capture HDR images, and registers for its events /// </summary> /// <returns></returns> private async Task EnableHdrAsync() { // No work to be done if there already is an AdvancedCapture if (_advancedCapture != null) return; // Explicitly choose HDR mode var settings = new AdvancedPhotoCaptureSettings { Mode = AdvancedPhotoMode.Hdr }; // Configure the mode _mediaCapture.VideoDeviceController.AdvancedPhotoControl.Configure(settings); // Prepare for an advanced capture _advancedCapture = await _mediaCapture.PrepareAdvancedPhotoCaptureAsync(ImageEncodingProperties.CreateJpeg()); Debug.WriteLine("Enabled HDR mode"); // Register for events published by the AdvancedCapture _advancedCapture.AllPhotosCaptured += AdvancedCapture_AllPhotosCaptured; _advancedCapture.OptionalReferencePhotoCaptured += AdvancedCapture_OptionalReferencePhotoCaptured; }
public AdvancedPhotoCaptureEvents(AdvancedPhotoCapture This) { this.This = This; }