Example #1
0
        void InitializeAndStartBarcodeScanning()
        {
            ScanSettings settings = ScanSettings.Create();

            int[] symbologiesToEnable = new int[] {
                Barcode.SymbologyEan13,
                Barcode.SymbologyEan8,
                Barcode.SymbologyUpca,
                Barcode.SymbologyDataMatrix,
                Barcode.SymbologyQr,
                Barcode.SymbologyCode39,
                Barcode.SymbologyCode128,
                Barcode.SymbologyInterleaved2Of5,
                Barcode.SymbologyUpce
            };

            foreach (int symbology in symbologiesToEnable)
            {
                settings.SetSymbologyEnabled(symbology, true);
            }

            SymbologySettings symSettings = settings.GetSymbologySettings(Barcode.SymbologyCode128);

            short[] activeSymbolCounts = new short[] {
                7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
            };
            symSettings.SetActiveSymbolCounts(activeSymbolCounts);
            barcodePicker = new BarcodePicker(this, settings);
            barcodePicker.SetOnScanListener(this);
            SetContentView(barcodePicker);
        }
        void InitializeBarcodeScanning()
        {
            ScanSettings settings = ScanSettings.Create();

            int[] symbologiesToEnable =
            {
                Barcode.SymbologyEan13,
                Barcode.SymbologyEan8,
                Barcode.SymbologyUpca,
                Barcode.SymbologyCode39,
                Barcode.SymbologyCode128,
                Barcode.SymbologyInterleaved2Of5,
                Barcode.SymbologyUpce
            };

            ScanAreaSettings scanAreaSettings = new ScanAreaSettings();

            scanAreaSettings.SquareCodeLocationConstraint = BarcodeScannerSettings.CodeLocationRestrict;
            scanAreaSettings.WideCodeLocationConstraint   = BarcodeScannerSettings.CodeLocationRestrict;
            scanAreaSettings.WideCodeLocationArea         = new RectF(0f, 0.475f, 1f, 0.525f);
            scanAreaSettings.SquareCodeLocationArea       = new RectF(0f, 0.3f, 1f, 0.7f);
            settings.AreaSettingsPortrait  = scanAreaSettings;
            settings.AreaSettingsLandscape = scanAreaSettings;
            settings.CodeDuplicateFilter   = 1000;

            foreach (int symbology in symbologiesToEnable)
            {
                settings.SetSymbologyEnabled(symbology, true);
            }

            barcodePicker = new BarcodePicker(this, settings);
            barcodePicker.OverlayView.SetGuiStyle(ScanOverlay.GuiStyleLaser);
            barcodePicker.SetOnScanListener(this);
            (FindViewById(Resource.Id.picker_container) as FrameLayout).AddView(barcodePicker, 0);
        }
        void InitializeAndStartBarcodeScanning()
        {
            // The scanning behavior of the barcode picker is configured through scan
            // settings. We start with empty scan settings and enable a generous set
            // of 1D symbologies. MatrixScan is currently only supported for 1D
            // symbologies, enabling 2D symbologies will result in unexpected results.
            // In your own apps, only enable the symbologies you actually need.
            ScanSettings settings = ScanSettings.Create();

            int[] symbologiesToEnable = new int[] {
                Barcode.SymbologyEan13,
                Barcode.SymbologyEan8,
                Barcode.SymbologyUpca,
                Barcode.SymbologyCode39,
                Barcode.SymbologyCode128,
                Barcode.SymbologyInterleaved2Of5,
                Barcode.SymbologyUpce
            };

            foreach (int symbology in symbologiesToEnable)
            {
                settings.SetSymbologyEnabled(symbology, true);
            }

            // Enable MatrixScan and set the max number of barcodes that can be recognized per frame
            // to some reasonable number for your use case. The max number of codes per frame does not
            // limit the number of codes that can be tracked at the same time, it only limits the
            // number of codes that can be newly recognized per frame.
            settings.MatrixScanEnabled        = true;
            settings.MaxNumberOfCodesPerFrame = 10;

            // Prefer the back-facing camera, if there is any.
            settings.CameraFacingPreference = ScanSettings.CameraFacingBack;

            barcodePicker = new BarcodePicker(this, settings);
            barcodePicker.OverlayView.SetGuiStyle(ScanOverlay.GuiStyleMatrixScan);

            // Set the GUI style to MatrixScan to see a visualization of the tracked barcodes. If you
            // would like to visualize it yourself, set it to ScanOverlay.GuiStyleNone and update your
            // visualization in the didProcess() callback.
            barcodePicker.OverlayView.SetGuiStyle(ScanOverlay.GuiStyleMatrixScan);

            // When using MatrixScan vibrating is often not desired.
            barcodePicker.OverlayView.SetVibrateEnabled(false);

            // Register listener, in order to be notified about relevant events
            // (e.g. a successfully scanned bar code).
            barcodePicker.SetOnScanListener(this);

            // Register a process frame listener to be able to reject tracked codes.
            barcodePicker.SetProcessFrameListener(this);

            // Set listener for the scan event.
            barcodePicker.SetOnScanListener(this);

            // Show the scan user interface
            SetContentView(barcodePicker);
        }
Example #4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

            // Set the app key before instantiating the picker.
            ScanditLicense.AppKey = appKey;

            // The scanning behavior of the barcode picker is configured through scan
            // settings. We start with empty scan settings and enable a very generous
            // set of symbologies. In your own apps, only enable the symbologies you
            // actually need.
            ScanSettings settings = ScanSettings.Create();

            int[] symbologiesToEnable = new int[] {
                Barcode.SymbologyEan13,
                Barcode.SymbologyEan8,
                Barcode.SymbologyUpca,
                Barcode.SymbologyDataMatrix,
                Barcode.SymbologyQr,
                Barcode.SymbologyCode39,
                Barcode.SymbologyCode128,
                Barcode.SymbologyInterleaved2Of5,
                Barcode.SymbologyUpce
            };

            for (int sym = 0; sym < symbologiesToEnable.Length; sym++)
            {
                settings.SetSymbologyEnabled(symbologiesToEnable[sym], true);
            }

            // Some 1d barcode symbologies allow you to encode variable-length data. By default, the
            // Scandit BarcodeScanner SDK only scans barcodes in a certain length range. If your
            // application requires scanning of one of these symbologies, and the length is falling
            // outside the default range, you may need to adjust the "active symbol counts" for this
            // symbology. This is shown in the following few lines of code.

            SymbologySettings symSettings = settings.GetSymbologySettings(Barcode.SymbologyCode128);

            short[] activeSymbolCounts = new short[] {
                7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
            };
            symSettings.SetActiveSymbolCounts(activeSymbolCounts);
            // For details on defaults and how to calculate the symbol counts for each symbology, take
            // a look at http://docs.scandit.com/stable/c_api/symbologies.html.

            picker = new BarcodePicker(this, settings);

            // Set listener for the scan event.
            picker.SetOnScanListener(this);

            // Show the scan user interface
            SetContentView(picker);
        }
Example #5
0
        void InitializeAndStartBarcodeScanning()
        {
            // The scanning behavior of the barcode picker is configured through scan
            // settings. We start with empty scan settings and enable a very generous
            // set of symbologies. In your own apps, only enable the symbologies you
            // actually need.
            ScanSettings settings = ScanSettings.Create();

            int[] symbologiesToEnable = new int[] {
                Barcode.SymbologyEan13,
                Barcode.SymbologyEan8,
                Barcode.SymbologyUpca,
                Barcode.SymbologyDataMatrix,
                Barcode.SymbologyQr,
                Barcode.SymbologyCode39,
                Barcode.SymbologyCode128,
                Barcode.SymbologyInterleaved2Of5,
                Barcode.SymbologyUpce
            };

            foreach (int symbology in symbologiesToEnable)
            {
                settings.SetSymbologyEnabled(symbology, true);
            }

            // Some 1d barcode symbologies allow you to encode variable-length data. By default, the
            // Scandit BarcodeScanner SDK only scans barcodes in a certain length range. If your
            // application requires scanning of one of these symbologies, and the length is falling
            // outside the default range, you may need to adjust the "active symbol counts" for this
            // symbology. This is shown in the following few lines of code.

            SymbologySettings symSettings = settings.GetSymbologySettings(Barcode.SymbologyCode128);

            short[] activeSymbolCounts = new short[] {
                7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
            };
            symSettings.SetActiveSymbolCounts(activeSymbolCounts);
            // For details on defaults and how to calculate the symbol counts for each symbology, take
            // a look at http://docs.scandit.com/stable/c_api/symbologies.html.

            barcodePicker = new BarcodePicker(this, settings);

            // Set listener for the scan event.
            barcodePicker.SetOnScanListener(this);

            // Show the scan user interface
            SetContentView(barcodePicker);
        }
Example #6
0
        protected ScanSettings GetScanSettings()
        {
            ScanSettings settings = ScanSettings.Create();

            settings.SetSymbologyEnabled(Barcode.SymbologyEan13, true);
            settings.SetSymbologyEnabled(Barcode.SymbologyUpce, true);
            settings.SetSymbologyEnabled(Barcode.SymbologyUpca, true);
            settings.SetSymbologyEnabled(Barcode.SymbologyEan8, true);
            settings.MatrixScanEnabled        = true;
            settings.MaxNumberOfCodesPerFrame = 12;
            settings.HighDensityModeEnabled   = true;
            settings.CodeCachingDuration      = 0;
            settings.CodeDuplicateFilter      = 0;

            return(settings);
        }
Example #7
0
        void InitializeBarcodeScanning()
        {
            ScanSettings settings = ScanSettings.Create();

            int[] symbologiesToEnable =
            {
                Barcode.SymbologyEan13,
                Barcode.SymbologyEan8,
                Barcode.SymbologyUpca,
                Barcode.SymbologyUpce,
                Barcode.SymbologyDataMatrix,
                Barcode.SymbologyQr,
                Barcode.SymbologyCode39,
                Barcode.SymbologyCode128,
                Barcode.SymbologyInterleaved2Of5
            };

            foreach (int symbology in symbologiesToEnable)
            {
                settings.SetSymbologyEnabled(symbology, true);
            }

            // Enable and set the restrict active area. This will make sure that codes are only scanned in a very thin band in the center of the image.
            settings.SetActiveScanningArea(ScanSettings.OrientationPortrait, new RectF(0f, 0.48f, 1f, 0.52f));

            // Setup the barcode scanner
            barcodePicker = new BarcodePicker(this, settings);

            // Add listener for the scan event. We keep references to the
            // delegates until the picker is no longer used as the delegates are softly
            // referenced and can be removed because of low memory.
            barcodePicker.SetOnScanListener(this);

            // Modify the GUI style to have a "laser" line instead of a square viewfinder.
            barcodePicker.OverlayView.SetGuiStyle(ScanOverlay.GuiStyleLaser);

            // Start scanning in paused state.
            barcodePicker.StartScanning(true);

            (FindViewById(Resource.Id.picker_container) as FrameLayout).AddView(barcodePicker, 0);

            GrantCameraPermissionsThenStartScanning();
        }
Example #8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
            ScanditLicense.AppKey = appKey;
            ScanSettings settings = ScanSettings.Create();

            int[] symbologiesToEnable = new int[] {
                Barcode.SymbologyEan13,
                Barcode.SymbologyEan8,
                Barcode.SymbologyUpca,
                Barcode.SymbologyDataMatrix,
                Barcode.SymbologyQr,
                Barcode.SymbologyCode39,
                Barcode.SymbologyCode128,
                Barcode.SymbologyInterleaved2Of5,
                Barcode.SymbologyUpce
            };

            for (int sym = 0; sym < symbologiesToEnable.Length; sym++)
            {
                settings.SetSymbologyEnabled(symbologiesToEnable[sym], true);
            }

            SymbologySettings symSettings = settings.GetSymbologySettings(Barcode.SymbologyCode128);

            short[] activeSymbolCounts = new short[] {
                7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
            };
            symSettings.SetActiveSymbolCounts(activeSymbolCounts);
            // For details on defaults and how to calculate the symbol counts for each symbology, take
            // a look at http://docs.scandit.com/stable/c_api/symbologies.html.

            picker = new BarcodePicker(this, settings);
            picker.SetOnScanListener(this);
            SetContentView(picker);
        }
        private ScanSettings CreateScanSettings()
        {
            var settings     = pickerView.Settings;
            var scanSettings = ScanSettings.Create();

            // Symbologies
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyEan13, settings.Ean13Upc12);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyUpca, settings.Ean13Upc12);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyEan8, settings.Ean8);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyUpce, settings.Upce);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyTwoDigitAddOn, settings.TwoDigitAddOn);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyFiveDigitAddOn, settings.FiveDigitAddOn);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyCode11, settings.Code11);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyCode25, settings.Code25);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyCode32, settings.Code32);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyCode39, settings.Code39);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyCode93, settings.Code93);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyCode128, settings.Code128);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyInterleaved2Of5, settings.Interleaved2Of5);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyMsiPlessey, settings.MsiPlessey);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyGs1Databar, settings.Gs1Databar);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyGs1DatabarExpanded, settings.Gs1DatabarExpanded);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyGs1DatabarLimited, settings.Gs1DatabarLimited);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyCodabar, settings.Codabar);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyQr, settings.Qr);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyDataMatrix, settings.DataMatrix);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyPdf417, settings.Pdf417);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyMicroPdf417, settings.MicroPdf417);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyAztec, settings.Aztec);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyMaxicode, settings.MaxiCode);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyRm4scc, settings.Rm4scc);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyKix, settings.Kix);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyDotcode, settings.Kix);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyMicroQr, settings.MicroQR);
            scanSettings.SetSymbologyEnabled(Barcode.SymbologyLapa4sc, settings.Lapa4sc);

            if (settings.QrInverted)
            {
                var qrSettings = scanSettings.GetSymbologySettings(Barcode.SymbologyQr);
                qrSettings.ColorInvertedEnabled = true;
            }

            var isScanningAreaOverridden = false;

            if (settings.DataMatrix)
            {
                var datamatrixSettings = scanSettings.GetSymbologySettings(Barcode.SymbologyDataMatrix);

                datamatrixSettings.ColorInvertedEnabled = settings.DataMatrixInverted;

                if (settings.DpmMode)
                {
                    scanSettings.RestrictedAreaScanningEnabled = true;
                    var scanninArea = new Android.Graphics.RectF(0.33f, 0.33f, 0.66f, 0.66f);
                    scanSettings.SetActiveScanningArea(ScanSettings.OrientationPortrait, scanninArea);
                    scanSettings.SetActiveScanningArea(ScanSettings.OrientationLandscape, scanninArea);

                    isScanningAreaOverridden = true;

                    // Enabling the direct_part_marking_mode extension comes at the cost of increased frame processing times.
                    // It is recommended to restrict the scanning area to a smaller part of the image for best performance.
                    datamatrixSettings.SetExtensionEnabled("direct_part_marking_mode", true);
                }
            }

            if (settings.RestrictScanningArea && !isScanningAreaOverridden)
            {
                float y      = (float)settings.HotSpotY;
                float width  = (float)settings.HotSpotWidth;
                float height = (float)settings.HotSpotHeight;
                scanSettings.SetScanningHotSpot(0.5f, y);
                var scanninArea = new Android.Graphics.RectF(0.5f - (width / 2), y - (height / 2), 0.5f + (width / 2), y + (height / 2));
                scanSettings.SetActiveScanningArea(ScanSettings.OrientationPortrait, scanninArea);
                scanSettings.SetActiveScanningArea(ScanSettings.OrientationLandscape, scanninArea);
            }

            scanSettings.MaxNumberOfCodesPerFrame = settings.TwoDigitAddOn || settings.FiveDigitAddOn ? 2 : 1;

            scanSettings.HighDensityModeEnabled = (settings.Resolution == Resolution.HD);

            scanSettings.MatrixScanEnabled = (settings.GuiStyle == GuiStyle.MatrixScan);

            return(scanSettings);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <CustomStackLayout> e)
        {
            base.OnElementChanged(e);

            //var test = this as ViewGroup;

            if (e.NewElement != null)
            {
                // Set the app key before instantiating the picker.
                ScanditLicense.AppKey = appKey;

                // The scanning behavior of the barcode picker is configured through scan
                // settings. We start with empty scan settings and enable a very generous
                // set of symbologies. In your own apps, only enable the symbologies you
                // actually need.
                ScanSettings settings            = ScanSettings.Create();
                int[]        symbologiesToEnable = new int[]
                {
                    Barcode.SymbologyEan13,
                    Barcode.SymbologyEan8,
                    Barcode.SymbologyUpca,
                    Barcode.SymbologyDataMatrix,
                    Barcode.SymbologyQr,
                    Barcode.SymbologyCode39,
                    Barcode.SymbologyCode128,
                    Barcode.SymbologyInterleaved2Of5,
                    Barcode.SymbologyUpce
                };

                for (int sym = 0; sym < symbologiesToEnable.Length; sym++)
                {
                    settings.SetSymbologyEnabled(symbologiesToEnable[sym], true);
                }

                //// Some 1d barcode symbologies allow you to encode variable-length data. By default, the
                //// Scandit BarcodeScanner SDK only scans barcodes in a certain length range. If your
                //// application requires scanning of one of these symbologies, and the length is falling
                //// outside the default range, you may need to adjust the "active symbol counts" for this
                //// symbology. This is shown in the following few lines of code.

                SymbologySettings symSettings        = settings.GetSymbologySettings(Barcode.SymbologyCode128);
                short[]           activeSymbolCounts = new short[]
                {
                    7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
                };
                symSettings.SetActiveSymbolCounts(activeSymbolCounts);
                // For details on defaults and how to calculate the symbol counts for each symbology, take
                // a look at http://docs.scandit.com/stable/c_api/symbologies.html.

                picker = new BarcodePicker(this.Context, settings);

                picker.OverlayView.SetViewfinderDimension(0.5f, 0.9f, 0.5f, 0.9f);
                picker.OverlayView.SetTorchEnabled(false);


                // Set listener for the scan event.
                picker.SetOnScanListener(this);

                picker.StartScanning();

                //picker.Scan += (sender, args) =>
                //{

                //};

                AddView(picker);

                //SetNativeControl(picker);
            }
        }
Example #11
0
        /// <summary>
        /// On element changed event
        /// </summary>
        /// <param name="e"></param>
        protected override void OnElementChanged(ElementChangedEventArgs <ScandItCamera> e)
        {
            base.OnElementChanged(e);
            //assign new elemnt value to scanned it camera
            _scanedItCamera = e.NewElement;

            if (Control == null)
            {
                ScanditLicense.AppKey = ScanditAppKey;
                var scanSettings = ScanSettings.Create();
                //set code duplication filter
                if (_scanedItCamera.AllowDuplicate)
                {
                    scanSettings.CodeDuplicateFilter = 1500; //1.5 sec delay for duplication scanning
                }
                else
                {
                    scanSettings.CodeDuplicateFilter = -1;
                }

                //Bar code symbologies
                scanSettings.SetSymbologyEnabled(Barcode.SymbologyEan13, true);
                scanSettings.SetSymbologyEnabled(Barcode.SymbologyEan8, true);
                scanSettings.SetSymbologyEnabled(Barcode.SymbologyQr, true);
                scanSettings.SetSymbologyEnabled(Barcode.SymbologyUpca, true);
                scanSettings.SetSymbologyEnabled(Barcode.SymbologyCode128, true);
                scanSettings.SetSymbologyEnabled(Barcode.SymbologyCode39, true);
                //set code length for code 128
                var code128Settings = scanSettings.GetSymbologySettings(Barcode.SymbologyCode128);
                code128Settings.SetActiveSymbolCounts(
                    new short[] { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
                                  28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 }
                    );
                scanSettings.SetActiveScanningArea(ScanSettings.OrientationPortrait, new RectF(0.0f, 0.45f, 1.0f, 0.55f));
                _picker = new BarcodePicker(_context, scanSettings);
                //set picker properties
                _picker.OverlayView.SetBeepEnabled(true);
                _picker.OverlayView.SetVibrateEnabled(true);
                _picker.OverlayView.SetCameraSwitchVisibility(0);
                //to set picker gui style
                if (_scanedItCamera.ShowFocus)
                {
                    _picker.OverlayView.SetGuiStyle(0);
                }
                else
                {
                    _picker.OverlayView.SetGuiStyle(3);
                }
                //_picker.StartScanning();
                _picker.SetOnScanListener(this);
                //apply picker scan sesstings
                _picker.ApplyScanSettings(scanSettings);
                SetNativeControl(_picker);

                //enable action for start and stop scanning
                if (_scanedItCamera != null)
                {
                    _scanedItCamera.StartScanning = StartScanning;
                    _scanedItCamera.StopScanning  = StopScanning;
                }
            }
        }