Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

ZXing Barcode Scanner accessing camera gets progressively slower when cameraopened

$
0
0

Hi,

Wondering if anyone has noticed this issue. I'm using the ZXing barcode Scanner in a view and each time a barcode is scanned I'm closing the scanner to give the user visbility of the scanned item.

I'm noticing that if the barcode scanner is opened and closed in fairly quick succession it get's progressively slower to open the camera:

05-09 16:21:37.356 D/ZXing.Net.Mobile(20427): Checking Number of cameras...
05-09 16:21:40.364 D/ZXing.Net.Mobile(20427): Found 2 cameras...

See the difference of nearly 3 seconds above for "Checking Number of Cameras" to "Found 2 Cameras".

Has anyone noticed this behaviour before?

To load the Scanner into the View:

        private void BtnAddScanAgent_Clicked(object sender, System.EventArgs e)
        {
            scannerView = new ZXingScannerView();

            scannerView.OnScanResult -= (result) => { HandleScanResult(result); };
            scannerView.OnScanResult += (result) => { HandleScanResult(result); };

            ScannedAgentsGrid.Children.Add(scannerView, 0, 0);

            scannerOverlay = new ZXingDefaultOverlay
            {
                TopText = "Hold your phone up to the barcode",
                BottomText = "Scanning will happen automatically",
                ShowFlashButton = false
            };

            ScannedAgentsGrid.Children.Add(scannerOverlay, 0, 0);

            scannerView.IsAnalyzing = true;
            scannerView.IsScanning = true;
        }

To remove Camera OnScanResult:

    private void HandleScanResult(Result result)
    {
        scannerView.IsAnalyzing = false;
        scannerView.IsScanning = false;

        Device.BeginInvokeOnMainThread(delegate
        {
                viewModel.QRScanResultCommand?.Execute(result);

                ScannedAgentsGrid.Children.Remove(scannerOverlay);
                ScannedAgentsGrid.Children.Remove(scannerView);

                scannerOverlay = null;
                scannerView = null;             
        });
    }

Thanks in advance for any assistance.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>