Std_Net
Std_Net

Reputation: 1096

MediaCapture change camera focus(WP8.1 and WinRt8.1)

I use MediaCapture like this

MediaCapture _capture = new MediaCapture();
await _capture.InitializeAsync();
await _capture.StartPreviewAsync();

and camera work. But I need to change camera focus from code. Did you know how to do this?

Upvotes: 2

Views: 5246

Answers (2)

Khurram
Khurram

Reputation: 883

You can focus using this line

_mediaCapture.VideoDeviceController.FocusControl.FocusAsync();

call this on a event, like on CaptureElement tapped event or set a focus button and call this when focus button is clicked or call it just before capturing the photo so the photo is captured after focusing.

Upvotes: 3

Romasz
Romasz

Reputation: 29792

MediaCapture class has a property VideoDeviceController which returns device controller.

You will find there all the properties of your camera along with focus and FocusControl. I've managed to change focus like this:

// first set mode to manual
await _capture.VideoDeviceController.FocusControl.SetPresetAsync(Windows.Media.Devices.FocusPreset.Manual);
await _capture.VideoDeviceController.FocusControl.SetValueAsync(100);
// but those two above are deprecated - it will work but I would advise to do it:
_capture.VideoDeviceController.FocusControl.Configure(new FocusSettings { Mode = FocusMode.Manual, Value = 100, DisableDriverFallback = true });
await _capture.VideoDeviceController.FocusControl.FocusAsync();

Upvotes: 5

Related Questions