Exemple #1
0
        public void BarcodeDetector_Builder()
        {
            var detector = new BarcodeDetector.Builder(Application.Context).Build();


            Assert.True(detector != null);
        }
Exemple #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.FaceTracker);

            mPreview        = FindViewById <CameraSourcePreview> (Resource.Id.preview);
            mGraphicOverlay = FindViewById <GraphicOverlay> (Resource.Id.faceOverlay);

            var detector = new BarcodeDetector.Builder(Application.Context)
                           .Build();

            detector.SetProcessor(
                new MultiProcessor.Builder(new GraphicBarcodeTrackerFactory(mGraphicOverlay)).Build());

            if (!detector.IsOperational)
            {
                // Note: The first time that an app using barcode API is installed on a device, GMS will
                // download a native library to the device in order to do detection.  Usually this
                // completes before the app is run for the first time.  But if that download has not yet
                // completed, then the above call will not detect any barcodes.
                //
                // IsOperational can be used to check if the required native library is currently
                // available.  The detector will automatically become operational once the library
                // download completes on device.
                Android.Util.Log.Warn(TAG, "Barcode detector dependencies are not yet available.");
            }

            mCameraSource = new CameraSource.Builder(Application.Context, detector)
                            .SetRequestedPreviewSize(640, 480)
                            .SetFacing(CameraFacing.Back)
                            .SetRequestedFps(15.0f)
                            .Build();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            ImageView imageView;
            Button    btnScan;
            EditText  edttxtResult;

            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            imageView    = FindViewById <ImageView>(Resource.Id.imageView);
            btnScan      = FindViewById <Button>(Resource.Id.btnScan);
            edttxtResult = FindViewById <EditText>(Resource.Id.txtResult);

            Bitmap bitMap = BitmapFactory.DecodeResource(ApplicationContext.Resources, Resource.Drawable.qrcode);

            imageView.SetImageBitmap(bitMap);

            btnScan.Click += delegate
            {
                BarcodeDetector detector = new BarcodeDetector.Builder(ApplicationContext).SetBarcodeFormats(BarcodeFormat.QrCode).Build();

                Android.Gms.Vision.Frame fram = new Android.Gms.Vision.Frame.Builder().SetBitmap(bitMap).Build();
                SparseArray barsCode          = detector.Detect(fram);
                Barcode     result            = (Barcode)barsCode.ValueAt(0);
                edttxtResult.Text = result.RawValue;
            };
        }
        public void InitCameraSource()
        {
            var detector = new BarcodeDetector.Builder(_applicationContext)
                           .Build();

            detector.SetProcessor(
                new MultiProcessor.Builder(new GraphicBarcodeTrackerFactory(_graphicOverlay)).Build());

            if (!detector.IsOperational)
            {
                // Note: The first time that an app using barcode API is installed on a device, GMS will
                // download a native library to the device in order to do detection.  Usually this
                // completes before the app is run for the first time.  But if that download has not yet
                // completed, then the above call will not detect any barcodes.
                //
                // IsOperational can be used to check if the required native library is currently
                // available.  The detector will automatically become operational once the library
                // download completes on device.
                Android.Util.Log.Warn(Tag, "Barcode detector dependencies are not yet available.");
            }

            _cameraSource = new CameraSource.Builder(_applicationContext, detector)
                            .SetRequestedPreviewSize(640, 480)
                            .SetFacing(CameraFacing.Back)
                            .SetRequestedFps(15.0f)
                            .SetAutoFocusEnabled(true)
                            .Build();

            StartCameraSource();
        }
        public static async Task <List <BarcodeResult> > ScanFromImage(byte[] imageArray)
        {
            BarcodeDetector detector = new BarcodeDetector.Builder(Android.App.Application.Context)
                                       .SetBarcodeFormats(Configuration.BarcodeFormats)
                                       .Build();
            Bitmap bitmap = BitmapFactory.DecodeByteArray(imageArray, 0, imageArray.Length);

            Android.Gms.Vision.Frame frame      = new Android.Gms.Vision.Frame.Builder().SetBitmap(bitmap).Build();
            SparseArray          qrcodes        = detector.Detect(frame);
            List <BarcodeResult> barcodeResults = new List <BarcodeResult>();

            for (int i = 0; i < qrcodes.Size(); i++)
            {
                Barcode barcode  = qrcodes.ValueAt(i) as Barcode;
                var     type     = Methods.ConvertBarcodeResultTypes(barcode.ValueFormat);
                var     value    = barcode.DisplayValue;
                var     rawValue = barcode.RawValue;
                barcodeResults.Add(new BarcodeResult
                {
                    BarcodeType  = type,
                    DisplayValue = value,
                    RawValue     = rawValue
                });
            }
            return(barcodeResults);
        }
        private RebuyCameraSource createCameraSource(Context context, BarcodeScanner barcodeScanner, CameraConfigurator configurator)
        {
            var barcodeDetector = new BarcodeDetector.Builder(context).Build();
            var barcodeFactory  = new BarcodeTrackerFactory(barcodeScanner);

            barcodeDetector.SetProcessor(new MultiProcessor.Builder(barcodeFactory).Build());

            return(new RebuyCameraSource.Builder(context, barcodeDetector)
                   .SetFacing(RebuyCameraSource.CameraFacingBack)
                   .SetConfigurator(configurator)
                   .Build());
        }
Exemple #7
0
        public BarcodeScannerRenderer(Context context) : base(context)
        {
            MainLayout =
                (ConstraintLayout)LayoutInflater.FromContext(context).Inflate(Resource.Layout.BarcodeTracker, null);
            AddView(MainLayout);
            CameraSourcePreview       = MainLayout.FindViewById <CameraSourcePreview>(Resource.Id.preview);
            CloseScannerButton        = MainLayout.FindViewById <ImageButton>(Resource.Id.closeScannerBtn);
            CloseScannerButton.Click += async delegate
            {
                await Xamarin.Forms.Application.Current.MainPage.Navigation.PopModalAsync();
            };

            MGraphicOverlay = MainLayout.FindViewById <GraphicOverlay>(Resource.Id.faceOverlay);

            BarcodeDetector detector = new BarcodeDetector.Builder(Application.Context)
                                       .Build();

            detector.SetProcessor(
                new MultiProcessor.Builder(new GraphicBarcodeTrackerFactory(MGraphicOverlay, this)).Build());

            if (!detector.IsOperational)
            {
                // Note: The first time that an app using barcode API is installed on a device, GMS will
                // download a native library to the device in order to do detection.  Usually this
                // completes before the app is run for the first time.  But if that download has not yet
                // completed, then the above call will not detect any barcodes.
                //
                // IsOperational can be used to check if the required native library is currently
                // available.  The detector will automatically become operational once the library
                // download completes on device.
                Android.Util.Log.Warn(TAG, "Barcode detector dependencies are not yet available.");
            }
            MCameraSource = new CameraSource.Builder(Application.Context, detector)
                            .SetAutoFocusEnabled(true)
                            .SetFacing(Android.Gms.Vision.CameraFacing.Back)
                            .SetRequestedFps(15.0f)
                            .Build();

            var torchFab      = FindViewById <FloatingActionButton>(Resource.Id.fab_torchlight);
            var hasFlashlight = Context.PackageManager.HasSystemFeature(PackageManager.FeatureCameraFlash);

            if (!hasFlashlight)
            {
                torchFab.Hide();
            }
            else
            {
                torchFab.Click += TorchFab_Click;
            }
            StartCameraSource();
        }
Exemple #8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            _cameraView  = (SurfaceView)FindViewById(Resource.Id.camera_view);
            _barcodeInfo = (TextView)FindViewById(Resource.Id.code_info);

            var barcodeDetector = new BarcodeDetector.Builder(this)
                                  .SetBarcodeFormats(BarcodeFormat.QrCode)
                                  .Build();

            barcodeDetector.SetProcessor(new Builder(this)
                                         .Build());

            _cameraSource = new CameraSource.Builder(this, barcodeDetector)
                            .SetRequestedPreviewSize(640, 900)
                            .SetAutoFocusEnabled(true)
                            .Build();
        }
Exemple #9
0
        private void CreateCameraSource()
        {
            var             context  = Application.Context;
            BarcodeDetector barcodes = new BarcodeDetector.Builder(context).Build();
            TextRecognizer  text     = new TextRecognizer.Builder(context).Build();
            MultiDetector   detector = new MultiDetector.Builder().Add(barcodes).Add(text).Build();

            barcodes.SetProcessor(new MultiProcessor.Builder(this).Build());
            text.SetProcessor(new MultiProcessor.Builder(this).Build());

            if (!detector.IsOperational)
            {
                Log.Warn(__CLASS__, "Detection is not ready");
            }

            mCameraSource = new CameraSource.Builder(context, detector)
                            .SetRequestedPreviewSize(512, 300)
                            .SetFacing(CameraFacing.Front)
                            .SetRequestedFps(15.0f)
                            .SetAutoFocusEnabled(true)
                            .Build();
        }
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            // 스케너 사용 가능여부 확인
            if (!CheckScannerStatus())
            {
                return;
            }

            if (CameraSource == null && Element.Width > 0 && Element.Height > 0)
            {
                // 바코드 검출 객체 설정 및 콜백 등록
                BarcodeDetector = new BarcodeDetector
                                  .Builder(Context)
                                  .SetBarcodeFormats(Element.BarcodeFormats.ToVisionFormat())
                                  .Build();
                BarcodeDetector.SetProcessor(this);
                this.Write("BarcodeDetector is created");

                // 프리뷰어 사이즈 얻기
                var previewerSize = Element.GetPreviewSize(Resources.DisplayMetrics);
                this.Write($"Previewer size - Width : {previewerSize.Width}, Height : {previewerSize.Height}");

                // 카메라 소스 생성
                CameraSource = new CameraSource
                               .Builder(Context, BarcodeDetector)
                               .SetFacing(CameraFacing.Back)
                               .SetRequestedPreviewSize(previewerSize.Width, previewerSize.Height)
                               .SetRequestedFps(10.0f)
                               .Build();
                this.Write("CameraSource is created");
            }

            switch (e.PropertyName)
            {
            case "IsTorchOn":
            {
                try
                {
                    if (Element.IsScanning && Camera != null)
                    {
                        var parameters = Camera.GetParameters();
                        parameters.FlashMode = Element.IsTorchOn ? TorchOn : TorchOff;
                        Camera.SetParameters(parameters);

                        this.Write($"IsTorchOn : {Element.IsTorchOn}");
                    }
                }
                catch (Exception ex)
                {
                    this.Write($"Camera exception : {ex.Message}, IsTorchOn : {Element.IsTorchOn}");
                }
                break;
            }

            case "IsPreviewing":
            case "IsScanning":
            {
                try
                {
                    if (Element.IsScanning && Element.IsPreviewing)
                    {
                        CameraSource?.Start(Control.Holder);
                        Camera = CameraSource?.GetCamera();
                        SetAutoFocusCallback();
                    }
                    else
                    {
                        Element.SetValue(BarcodeScanner.IsTorchOnProperty, false);
                        CameraSource?.Stop();
                    }
                }
                catch (Exception ex)
                {
                    var toggleValue = e.PropertyName == "IsScanning"
                                ? Element.IsScanning
                                : Element.IsPreviewing;

                    this.Write($"CameraSource exception : {ex.Message}, {e.PropertyName} : {toggleValue}");
                }

                this.Write($"{e.PropertyName} : {Element.IsScanning}");
                break;
            }
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            Window.SetFlags(WindowManagerFlags.KeepScreenOn, WindowManagerFlags.KeepScreenOn);

            base.OnCreate(bundle);

            ActionBar.SetHomeButtonEnabled(true);
            ActionBar.SetDisplayHomeAsUpEnabled(true);

            SetContentView(Resource.Layout.EnergyActivity);

            _scanView = FindViewById <EnergyScanView>(Resource.Id.energy_scan_view);

            _energyUseCase = Intent.Extras.GetSerializable("OBJECT").ToString();
            _scanView.SetConfigFromAsset(_energyUseCase.Equals(Resources.GetString(Resource.String.scan_heat_meter))
                ? "EnergyConfigHeatMeter.json"
                : "EnergyConfigAll.json");

            _scanView.InitAnyline(MainActivity.LicenseKey, this);

            NativeBarcodeResultTextView      = FindViewById <TextView>(Resource.Id.barcode_result_text);
            NativeBarcodeResultTextView.Text = "";

            _toggleBarcodeSwitch = FindViewById <Switch>(Resource.Id.toggle_barcode_switch);

            // we don't use the native barcode scan mode in heat meters in this example
            if (_energyUseCase.Equals(Resources.GetString(Resource.String.scan_heat_meter)))
            {
                var toggleBarcodeLayout = FindViewById <RelativeLayout>(Resource.Id.toggle_barcode_layout);
                toggleBarcodeLayout.Visibility = ViewStates.Gone;
            }
            else
            {
                _toggleBarcodeSwitch.CheckedChange += (sender, args) =>
                {
                    if (((Switch)sender).Checked)
                    {
                        /*
                         * Enable simultaneous barcode scanning:
                         *
                         * The following lines of code enable the simultaneous barcode scanning functionality.
                         * In order for this to work, some additional requires must be met in the project settings:
                         *
                         * In AndroidManifest.xml, the following must be added:
                         * <meta-data android:name="com.google.android.gms.vision.DEPENDENCIES" android:value="barcode" />
                         *
                         * Also, the Nuget Package "Xamarin.GooglePlayServices.Vision" must be installed for this application.
                         * For installation, the App must be targeted to Android 7.0, but then the SDK version can be reduced again.
                         */
                        try
                        {
                            // First, we check if the barcode detector works on the device
                            var detector = new BarcodeDetector.Builder(ApplicationContext).Build();
                            if (!detector.IsOperational)
                            {
                                // Native barcode scanning not supported on this device
                                Toast.MakeText(ApplicationContext, "Native Barcode scanning not supported on this device!", ToastLength.Long).Show();
                                _toggleBarcodeSwitch.Checked = false;
                            }
                            else
                            {
                                _nativeBarcodeResultListener?.Dispose(); // dispose of old barcodelistener first
                                _nativeBarcodeResultListener = new NativeBarcodeResultListener(this);
                                _scanView.EnableBarcodeDetection(true, _nativeBarcodeResultListener);
                            }
                        }
                        catch (Exception) { }
                    }
                    else
                    {
                        _scanView.DisableBarcodeDetection();
                        _nativeBarcodeResultListener?.Dispose();
                        NativeBarcodeResultTextView.Text = "";
                    }
                };
            }

            // In our main activity, we selected which type of meters we want to scan
            // Now we want to populate the RadioButton group accordingly:

            RadioGroup radioGroup   = FindViewById <RadioGroup>(Resource.Id.radio_group);
            int        defaultIndex = 0; //index for which radiobutton is checked at the beginning

            if (_energyUseCase.Equals(Resources.GetString(Resource.String.scan_analog_meter)))
            {
                SetTitle(Resource.String.scan_analog_meter);
                _scanView.SetScanMode(EnergyScanView.ScanMode.AnalogMeter);
            }
            else if (_energyUseCase.Equals(Resources.GetString(Resource.String.scan_digital_meter)))
            {
                SetTitle(Resource.String.scan_digital_meter);
                _scanView.SetScanMode(EnergyScanView.ScanMode.DigitalMeter);
            }
            else if (_energyUseCase.Equals(Resources.GetString(Resource.String.scan_heat_meter)))
            {
                SetTitle(Resource.String.scan_heat_meter);
                _scanList = new Dictionary <string, EnergyScanView.ScanMode>
                {
                    { Resources.GetString(Resource.String.heat_meter_4_3), EnergyScanView.ScanMode.HeatMeter4 },
                    { Resources.GetString(Resource.String.heat_meter_5_3), EnergyScanView.ScanMode.HeatMeter5 },
                    { Resources.GetString(Resource.String.heat_meter_6_3), EnergyScanView.ScanMode.HeatMeter6 }
                };

                _scanView.SetScanMode(_scanList.First().Value);

                // Adding an additional layout rule for this use case because of the radiobutton group size.
                var lp = NativeBarcodeResultTextView.LayoutParameters as RelativeLayout.LayoutParams;
                if (lp != null)
                {
                    lp.AddRule(LayoutRules.Above, radioGroup.Id);
                    NativeBarcodeResultTextView.LayoutParameters = lp;
                }
            }
            else if (_energyUseCase.Equals(Resources.GetString(Resource.String.scan_analog_digital_meter)))
            {
                SetTitle(Resource.String.scan_analog_digital_meter);
                _scanView.SetScanMode(EnergyScanView.ScanMode.AutoAnalogDigitalMeter);
            }
            else if (_energyUseCase.Equals(Resources.GetString(Resource.String.scan_serial_numbers)))
            {
                SetTitle(Resource.String.scan_serial_numbers);
                _scanView.SetScanMode(EnergyScanView.ScanMode.SerialNumber);

                // we can set the regex and character whitelist to improve SerialNumber scanning
                _scanView.SetSerialNumberCharWhitelist("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
                _scanView.SetSerialNumberValidationRegex("^[0-9A-Z]{5,}$");
            }
            else if (_energyUseCase.Equals(Resources.GetString(Resource.String.scan_dial_meters)))
            {
                SetTitle(Resource.String.scan_dial_meters);
                _scanView.SetScanMode(EnergyScanView.ScanMode.DialMeter);
            }
            else if (_energyUseCase.Equals(Resources.GetString(Resource.String.scan_dot_matrix_meters)))
            {
                SetTitle(Resource.String.scan_dot_matrix_meters);
                _scanView.SetScanMode(EnergyScanView.ScanMode.DotMatrixMeter);
            }
            Util.PopulateRadioGroupWithList(this, radioGroup, _scanList, defaultIndex);

            // Switch the scan mode depending on user selection

            radioGroup.CheckedChange += (sender, args) =>
            {
                _scanView.CancelScanning();

                var rb       = FindViewById <RadioButton>(args.CheckedId);
                var scanMode = _scanList.Single(x => x.Key.Equals(rb.Text)).Value;

                _scanView.SetScanMode(scanMode);
                _scanView.StartScanning();
            };

            _scanView.CameraOpened += (s, e) => { Log.Debug(TAG, "Camera opened successfully. Frame resolution " + e.Width + " x " + e.Height); };
            _scanView.CameraError  += (s, e) => { Log.Error(TAG, "OnCameraError: " + e.Event.Message); };

            _scanView.SetCancelOnResult(false);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.BarcodeTracker);

            //this.ActionBar.SetDisplayHomeAsUpEnabled(true);

            buttonFlash        = FindViewById <TextView>(Resource.Id.btnFlash2);
            buttonFlash.Click += ButtonFlash_Click;

            var buttonExit = FindViewById <ImageButton>(Resource.Id.btnExit);

            buttonExit.Click += ButtonExit_Click;

            Intent intent = new Intent(this.Intent);

            rowPosition = 0;
            IsContinue  = intent.GetBooleanExtra("IsContinue", false);
            IsFixed     = intent.GetBooleanExtra("IsFixed", false);

            AllScanBarcode       = intent.GetStringArrayListExtra("AllScanBarcode");
            ScanCompletedBarcode = intent.GetStringArrayListExtra("ScanCompletedBarcode");
            SaveCompletedBarcode = intent.GetStringArrayListExtra("SaveCompletedBarcode");

            mPreview        = FindViewById <CameraSourcePreview>(Resource.Id.preview);
            mGraphicOverlay = FindViewById <GraphicOverlay>(Resource.Id.barcodeOverlay);

            //mView = FindViewById<TouchView>(Resource.Id.left_top_view);
            //mView.setRec(rec);

            //BarcodeFormat supportBarcodeFormat = new BarcodeFormat();
            //supportBarcodeFormat |= BarcodeFormat.Code128;
            //supportBarcodeFormat |= BarcodeFormat.Ean13;

            string jsonList = Xamarin.Forms.Application.Current.Properties["SupportBarcodeFormat"].ToString();
            List <Helpers.BarcodeFormat> tmpList = JsonConvert.DeserializeObject <List <Helpers.BarcodeFormat> >(jsonList);

            Detector detector = null;

            //Xamarin.Android에서 AztecCode를 사용하기 위해서는 바코드 지원타입을 비워놔야 한다.
            //AztecCode 지원코드는 4096인데 Xamarin.Android에선 코드 타입이 없고 전체로 하면 스캔 가능한다.
            if (tmpList.Contains(Helpers.BarcodeFormat.AztecCode))
            {
                detector = new BarcodeDetector.Builder(Application.Context)
                           .Build();
            }
            else
            {
                var barcodeFormat = ConvertToAndroid(JsonConvert.DeserializeObject <List <Helpers.BarcodeFormat> >(jsonList));
                detector = new BarcodeDetector.Builder(Application.Context)
                           .SetBarcodeFormats(barcodeFormat)
                           .Build();
            }

            detector.SetProcessor(new MultiProcessor.Builder(new GraphicBarcodeTrackerFactory(mGraphicOverlay, this)).Build());

            //FocusingProcessor를 사용해도 되기는 하나 한번 포커스 지정되고 나서 연속 스캔할때 벗어나도 계속 스캐되는 버그가 있음.
            //detector.SetProcessor(new CentralBarcodeFocusingProcessor(detector, new GraphicBarcodeTracker(mGraphicOverlay, this)));

            if (!detector.IsOperational)
            {
                Android.Util.Log.Warn(TAG, "Barcode detector dependencies are not yet available.");
            }

            mCameraSource = new CameraSource.Builder(Application.Context, detector)
                            .SetRequestedPreviewSize((int)DeviceDisplay.MainDisplayInfo.Height, (int)DeviceDisplay.MainDisplayInfo.Width) //Max Size :  1920 x 1080 (아이폰과 동일함)
                                                                                                                                          //.SetRequestedPreviewSize(1600, 1200)
                            .SetFacing(CameraFacing.Back)
                            .SetRequestedFps(30.0f)                                                                                       //안드로이 공식샘플은 15.0f 로 되어 있으나 기본값은 30.0f
                            .SetAutoFocusEnabled(true)
                            .Build();

            _playerBeep    = MediaPlayer.Create(this, Resource.Raw.beep07); //Beep음 (Scandit과 동일함)
            _playerCaution = MediaPlayer.Create(this, Resource.Raw.beep06); //경고음.
        }
        public override void OnBindElements(View view)
        {
            try
            {
                CameraPreview            = view.FindViewById <SurfaceView>(Resource.Id.CameraPreview);
                CameraPreviewProgressBar = view.FindViewById <ProgressBar>(Resource.Id.CameraPreviewProgressBar);
                Vibrator  = (Vibrator)Activity.GetSystemService(Context.VibratorService);
                _callback = Arguments.GetBoolean(Constants.Callback);

                if (_callback)
                {
                    _onBarcodeReadListener = NavigationManager.LastFragment as IOnBarcodeReadListener;
                }

#if DEBUG
                _scannedBarcode = Guid.NewGuid().ToString();
                var token = CancelAndSetTokenForView(CameraPreview);
                if (!_callback)
                {
                    Task.Run(async() =>
                    {
                        var result = await ProductService.GetProductByBarcode(_scannedBarcode, token);

                        if (result.Error.Any())
                        {
                            var message = Resources.GetString(Resource.String.ProductBarcodeNotFound);
                            ShowToastMessage(message);

                            return;
                        }

                        RunOnUiThread(() =>
                        {
                            NavigationManager.GoToProductDetails(result.Data);
                        });
                    }, token);
                }
                else
                {
                    NavigationManager.GoToPrevious();
                }
#else
                var barcodeFormats = Arguments.GetIntArray(Constants.BarcodeFormats)
                                     .Cast <BarcodeFormat>()
                                     .Aggregate((acc, barfor) => acc | barfor);

                BarcodeDetector = new BarcodeDetector.Builder(Context)
                                  .SetBarcodeFormats(barcodeFormats)
                                  .Build();

                CameraSource = new CameraSource
                               .Builder(Context, BarcodeDetector)
                               .SetRequestedPreviewSize(640, 480)
                               .SetFacing(CameraFacing.Back)
                               .Build();

                BarcodeDetector.SetProcessor(this);

                CameraPreview.Holder.AddCallback(this);
                CameraPreviewProgressBar.Visibility = ViewStates.Invisible;
#endif
            }
            catch (System.Exception ex)
            {
                ShowToastMessage(ex.Message, ToastLength.Long);

                NavigationManager.GoToPrevious();
            }
        }