[英]Windows Phone 8.1 MediaCapture's FocusAsync does not work
我正在使用QR碼閱讀器實現Windows Phone 8.1應用程序。 我使用ZXing.NET分析拍攝的圖像並嘗試解析QR。 為了提高效率,我還為相機設置了自動對焦。 它在第一次啟動時效果很好,但是在第二次嘗試時(暫停后的速度-恢復或重新開始捕獲)效果不佳。 正如我測試的那樣,FocusAsync方法有時不會返回並阻止所有操作。
這里會發生什么? 可能是什么問題呢?
這是我當前的代碼。
焦點
var focusSettings = new Windows.Media.Devices.FocusSettings();
focusSettings.AutoFocusRange = Windows.Media.Devices.AutoFocusRange.Normal;
focusSettings.Mode = Windows.Media.Devices.FocusMode.Auto;
CaptureManager.VideoDeviceController.FocusControl.Configure(focusSettings);
主流程
... Initialization ...
ImageEncodingProperties imaggeProperties = ImageEncodingProperties.CreateJpeg();
imaggeProperties.Width = ViewModel.ImageWidth;
imaggeProperties.Height = ViewModel.ImageHeight;
InMemoryRandomAccessStream memoryStream = new InMemoryRandomAccessStream();
LoggingAdapter.Instance.WriteDebugLog("Scanning is in progress. " + Environment.CurrentManagedThreadId);
await CaptureManager.VideoDeviceController.FocusControl.FocusAsync();
await CaptureManager.CapturePhotoToStreamAsync(imaggeProperties, memoryStream);
LoggingAdapter.Instance.WriteDebugLog("Photo captured.");
var bcReader = new BarcodeReader();
... Processing the barcode ...
清潔用品
if (CaptureManager != null)
{
if (InProgress)
{
InProgress = false;
await CaptureManager.StopPreviewAsync();
}
CaptureManager.Dispose();
Capture.Source = null;
}
感謝前進!
我成功地實現了一個可行的解決方案。 我在FocusSettings中將WaitForFocus設置為false,並且似乎可以正常工作,也可以暫停或取消。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.