CameraPreviewImageSource.StartPreviewAsync doesn't work with videoEncodingProperties

1

I'm using CameraPreviewImageSource.PreviewFrameAvailable event to determine flashes by calculating average luminosity of each frame. For my purposes I don't need big frames, but with default settings StartPreviewAsync() method generates frames with size 1280*720px. I tried to use StartPreviewAsync(videoEncodingProperties) but every time I get an exception HRESULT:0x80040155 Interface not registered.

I can set preview frame size through underlying VideoDeviceController object, but it looks overcomplicated a bit, especially concerning that I have to set properties in a magically determined sequence (otherway the camera will be broken after exiting from the app).

await App.CameraPreviewImageSource.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoPreview, _previewProperties);
var properties = await App.CameraPreviewImageSource.StartPreviewAsync();
properties.Width = _previewProperties.Width;
properties.Height = _previewProperties.Height;

Am I doing something wrong or StartPreviewAsync(videoEncodingProperties) method in SDK simply doesn't work at all?

lumia-imaging-sdk
asked on Stack Overflow Jun 29, 2015 by Bounz

1 Answer

1

Well, "right" sequence of commands solves the problem:

var properties = await App.CameraPreviewImageSource.StartPreviewAsync();
await App.CameraPreviewImageSource.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoPreview, _previewProperties);
properties.Width = _previewProperties.Width;
properties.Height = _previewProperties.Height;
answered on Stack Overflow Dec 8, 2015 by Bounz

User contributions licensed under CC BY-SA 3.0