in src/CognitiveKioskUWP/MainPage.xaml.cs [483:509]
private async Task<SoftwareBitmap> TakeImage()
{
try
{
SoftwareBitmap savedImage;
// Get information about the preview
var previewProperties = mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) as VideoEncodingProperties;
// Create a video frame in the desired format for the preview frame
VideoFrame videoFrame = new VideoFrame(BitmapPixelFormat.Bgra8, (int)previewProperties.Width, (int)previewProperties.Height);
VideoFrame previewFrame = await mediaCapture.GetPreviewFrameAsync(videoFrame);
savedImage = previewFrame.SoftwareBitmap;
previewFrame.Dispose();
previewFrame = null;
return savedImage;
}
catch (Exception)
{
// eat error
}
return null;
}