I'm trying to capture an image from a running camera preview.
public async Task InitializeCamera()
{
var cameraID = await GetCameraID(Windows.Devices.Enumeration.Panel.Back);
var settings = new MediaCaptureInitializationSettings
{
StreamingCaptureMode = StreamingCaptureMode.Video,
VideoDeviceId = cameraID.Id,
};
_mediaCapture = new MediaCapture();
await _mediaCapture.InitializeAsync(settings);
_mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
Camera.Source = _mediaCapture;
await _mediaCapture.StartPreviewAsync();
MediaReader capture = await MediaReader.CreateFromMediaCaptureAsync(_mediaCapture);
// ...
}
But when calling CreateFromMediaCaptureAsync an exception is thrown:
An exception of type 'System.Exception' occurred in mscorlib.ni.dll but was not handled in user code
Additional information: The request is invalid in the current state. (Exception from HRESULT: 0xC00D36B2)
I don't get an exception when i uncomment the StartPreviewAsync line. But then i also get no preview...
I'm trying to capture an image from a running camera preview.
But when calling CreateFromMediaCaptureAsync an exception is thrown:
I don't get an exception when i uncomment the StartPreviewAsync line. But then i also get no preview...