UWP MediaCapture FocusAsync:操作无效
UWP MediaCapture FocusAsync: the op is invalid
我使用 MediapCapture 扫描二维码。这是我的配置:
var cameras = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
int cameraIndex = cameras.Count > 1 ? 1 : 0;
MediaCaptureInitializationSettings settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameras[cameraIndex].Id };
settings.StreamingCaptureMode = StreamingCaptureMode.Video;
await _mediaCapture.InitializeAsync();
SetResolution();
_mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
_mediaCapture.VideoDeviceController.FocusControl.Configure(new Windows.Media.Devices.FocusSettings() { Mode = Windows.Media.Devices.FocusMode.Auto });
videoCapture.Source = _mediaCapture;
await _mediaCapture.StartPreviewAsync();
我的 CaptureElement 上还有一个调用 FocusAsync 方法的 Tapped 事件:
await _mediaCapture.VideoDeviceController.FocusControl.FocusAsync();
我的问题是当我尝试集中注意力时有时(并非总是)出现错误(即使这是我第一次调用它)。这个错误是:
The op is invalid
编辑:
这是我的堆栈跟踪:(没有内部异常)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at ProjectName.Views.QrCodeScannerPage.d__8.MoveNext()
我使用 MediapCapture 扫描二维码。这是我的配置:
var cameras = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
int cameraIndex = cameras.Count > 1 ? 1 : 0;
MediaCaptureInitializationSettings settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameras[cameraIndex].Id };
settings.StreamingCaptureMode = StreamingCaptureMode.Video;
await _mediaCapture.InitializeAsync();
SetResolution();
_mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
_mediaCapture.VideoDeviceController.FocusControl.Configure(new Windows.Media.Devices.FocusSettings() { Mode = Windows.Media.Devices.FocusMode.Auto });
videoCapture.Source = _mediaCapture;
await _mediaCapture.StartPreviewAsync();
我的 CaptureElement 上还有一个调用 FocusAsync 方法的 Tapped 事件:
await _mediaCapture.VideoDeviceController.FocusControl.FocusAsync();
我的问题是当我尝试集中注意力时有时(并非总是)出现错误(即使这是我第一次调用它)。这个错误是:
The op is invalid
编辑:
这是我的堆栈跟踪:(没有内部异常)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at ProjectName.Views.QrCodeScannerPage.d__8.MoveNext()