ZXing.Net UWP相机冻结

时间:2018-11-21 12:33:05

标签: uwp qr-code zxing zxing.net

我已经使用来自https://github.com/Redth/ZXing.Net.Mobile的ZXing.Mobile.Net的源代码来进行UWP。我有冻结骆驼的问题。有时它可以正常工作,但有时在相机启动时,预览会显示带有随机像素的异常现象,几秒钟后就会冻结。

它总是在此行冻结:

var frame = await mediaCapture.GetPreviewFrameAsync(videoFrame)

没有引发异常或中断。

System.Diagnostics.Debug.WriteLine("Linija 243");
var delay = ScanningOptions.DelayBetweenAnalyzingFrames;

if (stopping || processing || !isAnalyzing
|| (mediaCapture == null || mediaCapture.CameraStreamState != Windows.Media.Devices.CameraStreamState.Streaming))
{
    timerPreview.Change(delay, Timeout.Infinite);
    return;
}

processing = true;
SoftwareBitmapLuminanceSource luminanceSource = null;
WriteableBitmap writeableBmp = null;
try
{
    System.Diagnostics.Debug.WriteLine("Linija 263");
    var frame = await mediaCapture.GetPreviewFrameAsync(videoFrame);
    luminanceSource = new SoftwareBitmapLuminanceSource(frame.SoftwareBitmap);
    System.Diagnostics.Debug.WriteLine("Linija 266");
}

我也可以在Output正常工作时发现此异常:

  

引发的异常:System.Private.CoreLib.dll中的“ System.ArgumentException”   GetPreviewFrame失败:System.ArgumentException:值不在预期范围内。      在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()      在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)      在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)      在System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()      在ZXing.Mobile.ZXingScannerControl处。<> c__DisplayClass16_0。 d.MoveNext()

0 个答案:

没有答案