我像这样使用MediaCapture
MediaCapture _capture = new MediaCapture();
await _capture.InitializeAsync();
await _capture.StartPreviewAsync();
和相机工作。但我需要从代码中改变相机焦点。你知道怎么做吗?
答案 0 :(得分:5)
MediaCapture类有一个属性VideoDeviceController,返回device controller。
您会发现相机的所有属性以及focus和FocusControl。我设法改变了这样的焦点:
// 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
点击事件或设置焦点按钮,并在点击焦点按钮时调用此功能,或在拍摄照片之前调用它,以便在对焦后拍摄照片。