LowLagPhotoCapture
LowLagPhotoCapture
LowLagPhotoCapture
LowLagPhotoCapture
Class
Definition
Provides methods for taking a low shutter lag photo.
public : sealed class LowLagPhotoCapture : ILowLagPhotoCapturepublic sealed class LowLagPhotoCapture : ILowLagPhotoCapturePublic NotInheritable Class LowLagPhotoCapture Implements ILowLagPhotoCapture// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Remarks
Use MediaCapture.PrepareLowLagPhotoCaptureAsync to initialize the capture. This is an asynchronous calls which returns a LowLagPhotoCapture object when it is finished. This must be called before CaptureAsync.
FinishAsync stops the photo capture operation and releases the LowLagPhotoCapture object and resources used by the capture photo operation. After starting a low lag photo capture, you must stop the photo capture by calling FinishAsync before your app attempts to record video with the MediaCapture object.
If the media type is changed or an effect is added, you must call MediaCapture.PrepareLowLagPhotoCaptureAsync to create a new LowLagPhotoCapture object.
For how-to guidance for using LowLagPhotoCapture to capture photos, see Basic photo, video, and audio capture with MediaCapture.
Methods
CaptureAsync() CaptureAsync() CaptureAsync() CaptureAsync()
Asynchronously captures a low shutter lag photo.
public : IAsyncOperation<CapturedPhoto> CaptureAsync()public IAsyncOperation<CapturedPhoto> CaptureAsync()Public Function CaptureAsync() As IAsyncOperation( Of CapturedPhoto )// You can use this method in JavaScript.
When this method completes, a CapturedPhoto object is returned which contains the captured photo.
Remarks
MediaCapture.PrepareLowLagPhotoCaptureAsync must be called before CaptureAsync.
When this asynchronous method completes, a CapturedPhoto object is returned which contains the captured photo.
FinishAsync() FinishAsync() FinishAsync() FinishAsync()
Asynchronously releases the LowLagPhotoCapture object and resources used by the capture photo operation.
public : IAsyncAction FinishAsync()public IAsyncAction FinishAsync()Public Function FinishAsync() As IAsyncAction// You can use this method in JavaScript.
Object that is used to control the asynchronous operation.
Examples
Here is an example that shows how to setup and take low lag photos. It displays the captured photo and thumbnail in Image objects. The XAML creates a simple UI with a two Image objects and some Button objects to interact with the MediaCapture element. In code, there is a method to initialize the MediaCapture object, a method to initialize the LowLagPhotoCapture object, a method to take the photo and display it, and a method to shutdown the LowLagPhotoCapture.
<StackPanel Orientation="Horizontal">
<Image x:Name="imageLowLagPhoto" Stretch="None"
Width="320" Height="240" />
<Image x:Name="imageLowLagThumbnail" Stretch="None"
Width="320" Height="240" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button Click="InitMediaCapture_Click" Content="Initialize Camera" />
<Button Click="InitLowLagPhotoCapture_Click" Content="Initialize Low Lag Photo Capture"/>
<Button Click="CaptureLagPhotoCapture_Click" Content="Capture Low Lag Photo"/>
<Button Click="CloseLagPhotoCapture_Click" Content="Finish low Lag Capture"/>
</StackPanel>
LowLagPhotoCapture lowLagCaptureMgr = null;
MediaCapture mediaCaptureManager;
async private void InitMediaCapture_Click(object sender, RoutedEventArgs e)
{
mediaCaptureManager = new MediaCapture();
await mediaCaptureManager.InitializeAsync();
}
async private void InitLowLagPhotoCapture_Click(object sender, RoutedEventArgs e)
{
// Enable thumbnail images
mediaCaptureManager.VideoDeviceController.LowLagPhoto.ThumbnailEnabled = true;
mediaCaptureManager.VideoDeviceController.LowLagPhoto.ThumbnailFormat = MediaThumbnailFormat.Bmp;
mediaCaptureManager.VideoDeviceController.LowLagPhoto.DesiredThumbnailSize = 25;
// Image properties
ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg();
// Create LowLagPhotoCapture object
lowLagCaptureMgr = await mediaCaptureManager.PrepareLowLagPhotoCaptureAsync(imgFormat);
}
async private void CaptureLagPhotoCapture_Click(object sender, RoutedEventArgs e)
{
// Take photo
CapturedPhoto photo = await lowLagCaptureMgr.CaptureAsync();
// Get photo as a BitmapImage
BitmapImage bitmap = new BitmapImage();
await bitmap.SetSourceAsync(photo.Frame);
// Get thumbnail as a BitmapImage
BitmapImage bitmapThumbnail = new BitmapImage();
await bitmapThumbnail.SetSourceAsync(photo.Thumbnail);
// imageLowLagPhoto is a <Image> object defined in XAML
imageLowLagPhoto.Source = bitmap;
// imageLowLagThumbnail is a <Image> object defined in XAML
imageLowLagThumbnail.Source = bitmapThumbnail;
}
async private void CloseLagPhotoCapture_Click(object sender, RoutedEventArgs e)
{
// Release the LowLagPhotoCapture object and resources
await lowLagCaptureMgr.FinishAsync();
}