简体   繁体   English

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

[英]MediaCapture change camera focus(WP8.1 and WinRt8.1)

I use MediaCapture like this 我像这样使用MediaCapture

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? 你知道怎么做吗?

MediaCapture class has a property VideoDeviceController which returns device controller . MediaCapture类有一个属性VideoDeviceController ,它返回设备控制器

You will find there all the properties of your camera along with focus and FocusControl . 你会发现你的相机的所有属性以及焦点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();

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. 在一个事件上调用它,比如在CaptureElement点击事件或设置一个焦点按钮,并在单击焦点按钮时调用它或在拍摄照片之前调用它,以便在聚焦后捕获照片。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM