MediaCapture更改相机焦点(WP8.1和WinRt8.1)

时间:2014-05-19 13:31:35

标签: c# windows-phone-8 windows-runtime windows-phone-8.1

我像这样使用MediaCapture

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

和相机工作。但我需要从代码中改变相机焦点。你知道怎么做吗?

2 个答案:

答案 0 :(得分:5)

MediaCapture类有一个属性VideoDeviceController,返回device controller

您会发现相机的所有属性以及focusFocusControl。我设法改变了这样的焦点:

// 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();

答案 1 :(得分:3)

您可以使用此行重点

_mediaCapture.VideoDeviceController.FocusControl.FocusAsync();

在事件上调用此功能,例如点击CaptureElement点击事件或设置焦点按钮,并在点击焦点按钮时调用此功能,或在拍摄照片之前调用它,以便在对焦后拍摄照片。