partial void scanButtonClicked(Foundation.NSObject sender) { // 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.DefaultSettings(); NSSet symbologiesToEnable = new NSSet( Symbology.EAN13, Symbology.EAN8, Symbology.UPC12, Symbology.UPCE, Symbology.Datamatrix, Symbology.QR, Symbology.Code39, Symbology.Code128, Symbology.ITF ); settings.EnableSymbologies(symbologiesToEnable); // 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 3 lines of code. NSMutableSet codeLengths = new NSMutableSet(); int i = 0; for (i = 7; i <= 20; i++) { codeLengths.Add(new NSNumber(i)); } settings.SettingsForSymbology(Symbology.Code128).ActiveSymbolCounts = codeLengths; // 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. // Setup the barcode scanner BarcodePicker picker = new BarcodePicker(settings); picker.OverlayView.ShowToolBar(true); // Add delegates for the scan and cancel 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. scanDelegate = new PickerScanDelegate(); picker.ScanDelegate = scanDelegate; cancelDelegate = new OverlayCancelDelegate(this, picker); picker.OverlayView.CancelDelegate = cancelDelegate; PresentViewController(picker, true, null); picker.StartScanning(); }
public override void ViewDidLoad() { base.ViewDidLoad(); // 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. Matrix scan 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.DefaultSettings(); NSSet symbologiesToEnable = new NSSet( Symbology.EAN13, Symbology.EAN8, Symbology.UPC12, Symbology.UPCE, Symbology.Code39, Symbology.Code128, Symbology.ITF ); // Enable matrix scan 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.EnableSymbologies(symbologiesToEnable); settings.MatrixScanEnabled = true; settings.MaxNumberOfCodesPerFrame = 10; settings.HighDensityModeEnabled = true; // When matrix scan is enabled beeping/vibrating is often not wanted. BarcodePicker picker = new BarcodePicker(settings); picker.OverlayView.SetBeepEnabled(false); picker.OverlayView.SetVibrateEnabled(false); // Register a SBSScanDelegate delegate, in order to be notified about relevant events // (e.g. a successfully scanned bar code). scanDelegate = new PickerScanDelegate(); picker.ScanDelegate = scanDelegate; // Register a SBSProcessFrameDelegate delegate to be able to reject tracked codes. processFrameDelegate = new PickerProcessFrameDelegate(); picker.ProcessFrameDelegate = processFrameDelegate; AddChildViewController(picker); picker.View.Frame = View.Bounds; Add(picker.View); picker.DidMoveToParentViewController(this); picker.OverlayView.GuiStyle = GuiStyle.MatrixScan; picker.StartScanning(); }
public override void ViewDidLoad() { base.ViewDidLoad(); // 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.DefaultSettings(); NSSet symbologiesToEnable = new NSSet( Symbology.EAN13, Symbology.EAN8, Symbology.UPC12, Symbology.UPCE, Symbology.Datamatrix, Symbology.QR, Symbology.Code39, Symbology.Code128, Symbology.ITF ); settings.EnableSymbologies(symbologiesToEnable); // 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(new CoreGraphics.CGRect(0, 0.48, 1, 0.04)); // Setup the barcode scanner picker = new BarcodePicker(settings); picker.OverlayView.ShowToolBar(false); // Add delegate 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. scanDelegate = new PickerScanDelegate(); picker.ScanDelegate = scanDelegate; AddChildViewController(picker); picker.View.Frame = View.Bounds; Add(picker.View); picker.DidMoveToParentViewController(this); // Modify the GUI style to have a "laser" line instead of a square viewfinder. picker.OverlayView.GuiStyle = GuiStyle.Laser; // Start scanning in paused state. picker.StartScanning(true); showAimAndScanButton(); }
private ScanSettings CreateScanSettings() { var settings = pickerView.Settings; var scanSettings = ScanSettings.DefaultSettings(); // Symbologies scanSettings.SetSymbologyEnabled(Symbology.EAN13, settings.Ean13Upc12); scanSettings.SetSymbologyEnabled(Symbology.UPC12, settings.Ean13Upc12); scanSettings.SetSymbologyEnabled(Symbology.EAN8, settings.Ean8); scanSettings.SetSymbologyEnabled(Symbology.UPCE, settings.Upce); scanSettings.SetSymbologyEnabled(Symbology.TwoDigitAddOn, settings.TwoDigitAddOn); scanSettings.SetSymbologyEnabled(Symbology.FiveDigitAddOn, settings.FiveDigitAddOn); scanSettings.SetSymbologyEnabled(Symbology.Code11, settings.Code11); scanSettings.SetSymbologyEnabled(Symbology.Code25, settings.Code25); scanSettings.SetSymbologyEnabled(Symbology.Code32, settings.Code32); scanSettings.SetSymbologyEnabled(Symbology.Code39, settings.Code39); scanSettings.SetSymbologyEnabled(Symbology.Code93, settings.Code93); scanSettings.SetSymbologyEnabled(Symbology.Code128, settings.Code128); scanSettings.SetSymbologyEnabled(Symbology.ITF, settings.Interleaved2Of5); scanSettings.SetSymbologyEnabled(Symbology.MSIPlessey, settings.MsiPlessey); scanSettings.SetSymbologyEnabled(Symbology.GS1Databar, settings.Gs1Databar); scanSettings.SetSymbologyEnabled(Symbology.GS1DatabarExpanded, settings.Gs1DatabarExpanded); scanSettings.SetSymbologyEnabled(Symbology.GS1DatabarLimited, settings.Gs1DatabarLimited); scanSettings.SetSymbologyEnabled(Symbology.Codabar, settings.Codabar); scanSettings.SetSymbologyEnabled(Symbology.QR, settings.Qr); scanSettings.SetSymbologyEnabled(Symbology.Datamatrix, settings.DataMatrix); scanSettings.SetSymbologyEnabled(Symbology.PDF417, settings.Pdf417); scanSettings.SetSymbologyEnabled(Symbology.MicroPDF417, settings.MicroPdf417); scanSettings.SetSymbologyEnabled(Symbology.Aztec, settings.Aztec); scanSettings.SetSymbologyEnabled(Symbology.MaxiCode, settings.MaxiCode); scanSettings.SetSymbologyEnabled(Symbology.RM4SCC, settings.Rm4scc); scanSettings.SetSymbologyEnabled(Symbology.KIX, settings.Kix); scanSettings.SetSymbologyEnabled(Symbology.DotCode, settings.Kix); scanSettings.SetSymbologyEnabled(Symbology.MicroQr, settings.MicroQR); scanSettings.SetSymbologyEnabled(Symbology.LAPA4SC, settings.Lapa4sc); if (settings.QrInverted) { var qrSettings = scanSettings.SettingsForSymbology(Symbology.QR); qrSettings.ColorInvertedEnabled = true; } var isScanningAreaOverridden = false; if (settings.DataMatrix) { var datamatrixSettings = scanSettings.SettingsForSymbology(Symbology.Datamatrix); datamatrixSettings.ColorInvertedEnabled = settings.DataMatrixInverted; if (settings.DpmMode) { scanSettings.RestrictedAreaScanningEnabled = true; var scanninArea = new CoreGraphics.CGRect(0.33f, 0.33f, 0.33f, 0.33f); scanSettings.SetActiveScanningArea(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) { var y = settings.HotSpotY; var width = settings.HotSpotWidth; var height = settings.HotSpotHeight; scanSettings.ScanningHotSpot = new CoreGraphics.CGPoint(0.5, y); var scanninArea = new CoreGraphics.CGRect(0.5 - width / 2, y - (height / 2), width, height); scanSettings.SetActiveScanningArea(scanninArea); } if (settings.TwoDigitAddOn || settings.FiveDigitAddOn) { scanSettings.MaxNumberOfCodesPerFrame = 2; } else { scanSettings.MaxNumberOfCodesPerFrame = 1; } scanSettings.HighDensityModeEnabled = (settings.Resolution == Resolution.HD); scanSettings.MatrixScanEnabled = (settings.GuiStyle == GuiStyle.MatrixScan); return(scanSettings); }
/// <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) { try { var scanLicense = new ScanditLicense(); scanLicense.AppKey = ScanditAppKey; ScanSettings scanSettings = ScanSettings.DefaultSettings(); //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(Symbology.EAN13, true); scanSettings.SetSymbologyEnabled(Symbology.QR, true); scanSettings.SetSymbologyEnabled(Symbology.UPC12, true); scanSettings.SetSymbologyEnabled(Symbology.Code128, true); scanSettings.SetSymbologyEnabled(Symbology.Code39, true); scanSettings.SetSymbologyEnabled(Symbology.EAN8, true); //update code 128 settings var code128Settings = scanSettings.SettingsForSymbology(Symbology.Code128); var countArray = NSArray.FromObjects(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); code128Settings.ActiveSymbolCounts = new NSSet(countArray); //apply scan settings _picker = new BarcodePicker(scanSettings); _picker.OverlayView.SetBeepEnabled(true); _picker.OverlayView.SetVibrateEnabled(true); _picker.OverlayView.SetCameraSwitchVisibility(CameraSwitchVisibility.Never); _picker.OverlayView.GuiStyle = GuiStyle.None; //to set picker gui style if (_scanedItCamera.ShowFocus) { _picker.OverlayView.GuiStyle = GuiStyle.Default; } else { _picker.OverlayView.GuiStyle = GuiStyle.None; } _picker.DidScan += DidScan; //set native control as picker view SetNativeControl(_picker.View); //enable action for start and stop scanning if (_scanedItCamera != null) { _scanedItCamera.StartScanning = StartScanning; _scanedItCamera.StopScanning = StopScanning; } } catch (Exception ex) { Debug.WriteLine(ex); } } }
public override void ViewDidLoad() { base.ViewDidLoad(); contatinerView = new UIView(CGRect.Empty); View.AddSubview(contatinerView); freezeButton = new UIButton(CGRect.Empty); freezeButton.SetTitle("Freeze", UIControlState.Normal); freezeButton.SetBackgroundImage(UIImageExtensions.Brand.GetImage(), UIControlState.Normal); freezeButton.TouchUpInside += (sender, e) => { var scanning = picker.IsScanning(); if (scanning) { matrixScanHandler.Enabled = false; picker.PauseScanning(); freezeButton.SetTitle("Done", UIControlState.Normal); } else { matrixScanHandler.RemoveAllAugmentations(); matrixScanHandler.Enabled = true; picker.StartScanning(); freezeButton.SetTitle("Freeze", UIControlState.Normal); } }; View.AddSubview(freezeButton); freezeButton.TranslatesAutoresizingMaskIntoConstraints = false; contatinerView.TranslatesAutoresizingMaskIntoConstraints = false; View.AddConstraints(new[] { contatinerView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), contatinerView.TopAnchor.ConstraintEqualTo(View.TopAnchor), contatinerView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), contatinerView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor), freezeButton.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor, 20), freezeButton.BottomAnchor.ConstraintEqualTo(View.BottomAnchor, -20), freezeButton.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor, -20), freezeButton.HeightAnchor.ConstraintEqualTo(60) }); var settings = ScanSettings.DefaultSettings(); settings.SetSymbologyEnabled(Symbology.EAN13, true); settings.MatrixScanEnabled = true; settings.MaxNumberOfCodesPerFrame = 15; settings.HighDensityModeEnabled = true; picker = new BarcodePicker(settings); picker.OverlayView.GuiStyle = GuiStyle.None; matrixScanHandler = new MatrixScanHandler(picker); matrixScanHandler.ShouldReject += (matrixScanHandler, trackedBarcode) => false; // This delegate method is called every time a new frame has been processed. // In this case we use it to update the offset of the augmentation. matrixScanHandler.DidProcess += (sender, e) => { DispatchQueue.MainQueue.DispatchAsync(() => { foreach (var item in e.Frame.TrackedCodes) { var offset = GetYOffSet(item.Value as TrackedBarcode); viewBasedMatrixScanOverlay.SetOffset(offset, item.Key as NSNumber); } }); }; viewBasedMatrixScanOverlay = new ViewBasedMatrixScanOverlay(); // This method is called every time a new barcode has been tracked. // You can implement this method to return the offset that will be used to position the augmentation // with respect to the center of the tracked barcode. viewBasedMatrixScanOverlay.OffsetForOverlay += (overlay, barcode, identifier) => GetYOffSet(barcode); // This delegate method is called every time a new barcode has been tracked. // You can implement this method to return the view that will be used as the augmentation. viewBasedMatrixScanOverlay.ViewForOverlay += (overlay, barcode, identifier) => { if (barcode.Data == null) { return(new UIView(CGRect.Empty)); } var view = new StockView(new CGRect(0, 0, StockView.StandardWidth, StockView.StandardHeight)); var model = Model.MockedModel(barcode.Data); view.AddGestureRecognizer(new UITapGestureRecognizer(() => { var overlayViewController = new OverlayViewController { Model = model, ModalTransitionStyle = UIModalTransitionStyle.CoverVertical, ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext }; PresentViewController(overlayViewController, false, null); })); view.Model = model; return(view); }; // Add a ViewBasedMatrixScanOverlay in order to have custom UIView instances as augmentations. matrixScanHandler.AddOverlay(viewBasedMatrixScanOverlay); simpleMatrixScanOverlay = new SimpleMatrixScanOverlay(); // This method is called every time a new barcode has been tracked. // You can implement this method to customize the color of the highlight. simpleMatrixScanOverlay.ColorForOverlay += (overlay, barcode, identifier) => Model.MockedColor(barcode.Data); // Add a SimpleMatrixScanOverlay in order to highlight the barcodes. matrixScanHandler.AddOverlay(simpleMatrixScanOverlay); AddChildViewController(picker); picker.View.Frame = contatinerView.Frame; picker.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; contatinerView.AddSubview(picker.View); picker.DidMoveToParentViewController(this); picker.StartScanning(); }