ZXing.Net UWP camera freeze

300 Views Asked by At

I've used source code from ZXing.Mobile.Net from https://github.com/Redth/ZXing.Net.Mobile for UWP. I have issue with camere freeze. Sometimes it works without issue, but sometimes when camera start, preview showing some anomaly with random pixels, and after few seconds it freeze.

Its always freezes at this line:

var frame = await mediaCapture.GetPreviewFrameAsync(videoFrame)

without throwing exception or break.

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");
}

Also i found this exception in Output when it works fine:

Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.dll GetPreviewFrame Failed: System.ArgumentException: Value does not fall within the expected range. at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at ZXing.Mobile.ZXingScannerControl.<>c__DisplayClass16_0.<b__1>d.MoveNext()

0

There are 0 best solutions below