private void InitializeAndStartBarcodeScanning() { // Create data capture context using your license key. this.dataCaptureContext = DataCaptureContext.ForLicenseKey(SCANDIT_LICENSE_KEY); // Use the default camera with the recommended camera settings for the BarcodeCapture mode // and set it as the frame source of the context. The camera is off by default and must be // turned on to start streaming frames to the data capture context for recognition. // See resumeFrameSource and pauseFrameSource below. this.camera = Camera.GetDefaultCamera(); if (this.camera == null) { throw new NullReferenceException( "Sample depends on a camera, which failed to initialize."); } // Use the settings recommended by barcode capture. this.dataCaptureContext.SetFrameSourceAsync(this.camera); // The settings instance initially has all types of barcodes (symbologies) disabled. For the purpose of this // sample we enable the QR symbology. In your own app ensure that you only enable the symbologies that your app // requires as every additional enabled symbology has an impact on processing times. var barcodeCaptureSettings = BarcodeCaptureSettings.Create(); barcodeCaptureSettings.EnableSymbology(Symbology.Qr, true); // Create new barcode capture mode with the settings from above. barcodeCapture = BarcodeCapture.Create(dataCaptureContext, barcodeCaptureSettings); // By default, every time a barcode is scanned, a sound (if not in silent mode) and a // vibration are played. In the following we are setting a success feedback without sound // and vibration. barcodeCapture.Feedback.Success = new Feedback(); // Register self as a listener to get informed whenever a new barcode got recognized. barcodeCapture.AddListener(this); // To visualize the on-going barcode capturing process on screen, setup a data capture view // that renders the camera preview. The view must be connected to the data capture context. this.dataCaptureView = DataCaptureView.Create(this, this.dataCaptureContext); // Add a barcode capture overlay to the data capture view to render the location of captured // barcodes on top of the video preview. // This is optional, but recommended for better visual feedback. overlay = BarcodeCaptureOverlay.Create(this.barcodeCapture, this.dataCaptureView); // Add a square viewfinder as we are only scanning square QR codes. overlay.Viewfinder = RectangularViewfinder.Create(RectangularViewfinderStyle.Square, RectangularViewfinderLineStyle.Light); // Adjust the overlay's barcode highlighting to match the new viewfinder styles and improve the visibility of feedback. // With 6.10 we will introduce this visual treatment as a new style for the overlay. this.highlightingBrush = new Brush(fillColor: Android.Graphics.Color.Transparent, strokeColor: Android.Graphics.Color.White, strokeWidth: 3); overlay.Brush = this.highlightingBrush; SetContentView(this.dataCaptureView); }
private void InitializeAndStartBarcodeScanning() { // Create data capture context using your license key. this.dataCaptureContext = DataCaptureContext.ForLicenseKey(SCANDIT_LICENSE_KEY); // Use the default camera and set it as the frame source of the context. // The camera is off by default and must be turned on to start // streaming frames to the data capture context for recognition. // See ResumeFrameSource and OnPause methods. this.camera = Camera.GetDefaultCamera(); if (this.camera != null) { // Use the recommended camera settings for the BarcodeTracking mode. CameraSettings cameraSettings = BarcodeTracking.RecommendedCameraSettings; // Adjust camera settings - set Full HD resolution. cameraSettings.PreferredResolution = VideoResolution.FullHd; this.camera.ApplySettingsAsync(cameraSettings); this.dataCaptureContext.SetFrameSourceAsync(this.camera); } // The barcode tracking process is configured through barcode tracking settings // which are then applied to the barcode tracking instance that manages barcode tracking. BarcodeTrackingSettings barcodeTrackingSettings = BarcodeTrackingSettings.Create(); // The settings instance initially has all types of barcodes (symbologies) disabled. // For the purpose of this sample we enable a very generous set of symbologies. // In your own app ensure that you only enable the symbologies that your app requires // as every additional enabled symbology has an impact on processing times. HashSet <Symbology> symbologies = new HashSet <Symbology>(); symbologies.Add(Symbology.Ean13Upca); symbologies.Add(Symbology.Ean8); symbologies.Add(Symbology.Upce); symbologies.Add(Symbology.Code39); symbologies.Add(Symbology.Code128); barcodeTrackingSettings.EnableSymbologies(symbologies); // Create barcode tracking and attach to context. this.barcodeTracking = BarcodeTracking.Create(this.dataCaptureContext, barcodeTrackingSettings); // Register self as a listener to get informed of tracked barcodes. this.barcodeTracking.AddListener(this); // To visualize the on-going barcode tracking process on screen, setup a data capture view // that renders the camera preview. The view must be connected to the data capture context. this.dataCaptureView = DataCaptureView.Create(this, this.dataCaptureContext); // Create barcode tracking overlay to the data capture view to render the tracked barcodes on // top of the video preview. This is optional, but recommended for better visual feedback. BarcodeTrackingBasicOverlay.Create(this.barcodeTracking, this.dataCaptureView); // Add the DataCaptureView to the container. FrameLayout container = this.FindViewById <FrameLayout>(Resource.Id.data_capture_view_container); container.AddView(this.dataCaptureView); }
private void SetupRecognition() { // Create data capture context using your license key. this.context = DataCaptureContextExtensions.LicensedContext; // Use the camera and set it as the frame source of the context. The camera is off by // default and must be turned on to start streaming frames to the data capture context for recognition. // See viewWillAppear and viewDidDisappear above. this.context.SetFrameSourceAsync(this.camera); // Use the recommended camera settings for the BarcodeTracking mode as default settings. // The preferred resolution is automatically chosen, which currently defaults to HD on all devices. // Setting the preferred resolution to full HD helps to get a better decode range. var cameraSettings = BarcodeTracking.RecommendedCameraSettings; cameraSettings.PreferredResolution = VideoResolution.Uhd4k; this.camera?.ApplySettingsAsync(cameraSettings); // The barcode tracking process is configured through barcode tracking settings // and are then applied to the barcode tracking instance that manages barcode tracking. var settings = BarcodeTrackingSettings.Create(BarcodeTrackingScenario.A); // The settings instance initially has all types of barcodes (symbologies) disabled. For the purpose of this // sample we enable a very generous set of symbologies. In your own app ensure that you only enable the // symbologies that your app requires as every additional enabled symbology has an impact on processing times. settings.EnableSymbologies(new HashSet <Symbology> { Symbology.Ean13Upca, Symbology.Ean8, Symbology.Upce, Symbology.Code39, Symbology.Code128 }); // Create new barcode tracking mode with the settings from above. this.barcodeTracking = BarcodeTracking.Create(this.context, settings); this.barcodeTracking.AddListener(this); // To visualize the on-going barcode tracking process on screen, setup a data capture view that renders the // camera preview. The view must be connected to the data capture context. this.captureView = DataCaptureView.Create(this.context, this.View.Bounds); this.captureView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; this.View.AddSubview(this.captureView); this.View.SendSubviewToBack(this.captureView); // Add a barcode tracking overlay to the data capture view to render the tracked barcodes on top of the video // preview. This is optional, but recommended for better visual feedback. The overlay is automatically added // to the view. this.basicOverlay = BarcodeTrackingBasicOverlay.Create(this.barcodeTracking, this.captureView); this.basicOverlay.Listener = this; // Add another barcode tracking overlay to the data capture view to render other views. The overlay is // automatically added to the view. this.advancedOverlay = BarcodeTrackingAdvancedOverlay.Create(this.barcodeTracking, this.captureView); this.advancedOverlay.Listener = this; }
protected void InitializeAndStartBarcodeScanning() { // Create data capture context using your license key. this.dataCaptureContext = DataCaptureContext.ForLicenseKey(SCANDIT_LICENSE_KEY); // Use the default camera and set it as the frame source of the context. // The camera is off by default and must be turned on to start streaming frames to the data // capture context for recognition. // See resumeFrameSource and pauseFrameSource below. this.camera = Camera.GetDefaultCamera(); if (this.camera != null) { // Use the settings recommended by barcode capture. this.dataCaptureContext.SetFrameSourceAsync(this.camera); } // Use the recommended camera settings for the BarcodeTracking mode as default settings. // The preferred resolution is automatically chosen, which currently defaults to HD on all devices. CameraSettings cameraSettings = BarcodeTracking.RecommendedCameraSettings; // Setting the preferred resolution to full HD helps to get a better decode range. cameraSettings.PreferredResolution = VideoResolution.FullHd; camera?.ApplySettingsAsync(cameraSettings); BarcodeTrackingSettings barcodeTrackingSettings = BarcodeTrackingSettings.Create(); // The settings instance initially has all types of barcodes (symbologies) disabled. // For the purpose of this sample we enable a very generous set of symbologies. // In your own app ensure that you only enable the symbologies that your app requires as // every additional enabled symbology has an impact on processing times. HashSet <Symbology> symbologies = new HashSet <Symbology>() { Symbology.Ean13Upca, Symbology.Ean8, Symbology.Upce, Symbology.Code39, Symbology.Code128 }; barcodeTrackingSettings.EnableSymbologies(symbologies); // Create new barcode tracking mode with the settings from above. this.barcodeTracking = BarcodeTracking.Create(this.dataCaptureContext, barcodeTrackingSettings); // Register self as a listener to get informed whenever a new barcode got recognized. this.barcodeTracking.AddListener(this); // To visualize the on-going barcode tracking process on screen, setup a data capture view // that renders the camera preview. The view must be connected to the data capture context. var dataCaptureView = DataCaptureView.Create(this.dataCaptureContext, this.View.Bounds); dataCaptureView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; this.View.AddSubview(dataCaptureView); this.View.SendSubviewToBack(dataCaptureView); BarcodeTrackingBasicOverlay.Create(this.barcodeTracking, dataCaptureView); }
protected void InitializeAndStartBarcodeScanning() { // Create data capture context using your license key. this.dataCaptureContext = DataCaptureContext.ForLicenseKey(SCANDIT_LICENSE_KEY); // Use the default camera and set it as the frame source of the context. // The camera is off by default and must be turned on to start streaming frames to the data // capture context for recognition. // See resumeFrameSource and pauseFrameSource below. this.camera = Camera.GetDefaultCamera(); if (this.camera != null) { // Use the settings recommended by barcode capture. this.camera.ApplySettingsAsync(BarcodeCapture.RecommendedCameraSettings); this.dataCaptureContext.SetFrameSourceAsync(this.camera); } BarcodeCaptureSettings barcodeCaptureSettings = BarcodeCaptureSettings.Create(); // The settings instance initially has all types of barcodes (symbologies) disabled. // For the purpose of this sample we enable the QR symbology. In your own app ensure // that you only enable the symbologies that your app requires as every additional // enabled symbology has an impact on processing times. barcodeCaptureSettings.EnableSymbology(Symbology.Qr, true); // Create new barcode capture mode with the settings from above. this.barcodeCapture = BarcodeCapture.Create(this.dataCaptureContext, barcodeCaptureSettings); // By default, every time a barcode is scanned, a sound (if not in silent mode) and a // vibration are played. In the following we are setting a success feedback without sound // and vibration. this.barcodeCapture.Feedback.Success = new Feedback(vibration: null, sound: null); // Register self as a listener to get informed whenever a new barcode got recognized. this.barcodeCapture.AddListener(this); // To visualize the on-going barcode capturing process on screen, setup a data capture view // that renders the camera preview. The view must be connected to the data capture context. this.dataCaptureView = DataCaptureView.Create(this.dataCaptureContext, this.View.Bounds); this.dataCaptureView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; this.View.AddSubview(this.dataCaptureView); this.overlay = BarcodeCaptureOverlay.Create(this.barcodeCapture, this.dataCaptureView); this.overlay.Viewfinder = RectangularViewfinder.Create(RectangularViewfinderStyle.Square, RectangularViewfinderLineStyle.Light); // Adjust the overlay's barcode highlighting to match the new viewfinder styles and improve the visibility of feedback. // With 6.10 we will introduce this visual treatment as a new style for the overlay. this.highlightingBrush = new Brush(fillColor: UIColor.Clear, strokeColor: UIColor.White, strokeWidth: 3); overlay.Brush = this.highlightingBrush; this.dataCaptureView.AddOverlay(this.overlay); }
private void SetupRecognition() { // Register this as a listener to get informed whenever a // new barcode got recognized. this.BarcodeCapture.AddListener(this); // To visualize the on-going barcode capturing process on screen, // setup a data capture view that renders the camera preview. // The view must be connected to the data capture context. this.dataCaptureView = DataCaptureView.Create(Context, View.Bounds); this.dataCaptureView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; this.View.AddSubview(this.dataCaptureView); this.View.SendSubviewToBack(this.dataCaptureView); SettingsManager.Instance.CaptureView = this.dataCaptureView; }
public override void ViewDidLoad() { base.ViewDidLoad(); DataCaptureManager.Instance.InitializeAndStartScanning(); // To visualize the on-going capturing process on screen, setup a data capture view // that renders the camera preview. The view must be connected to the data capture context. this.dataCaptureView = DataCaptureView.Create(DataCaptureManager.Instance.DataCaptureContext, this.View.Bounds); this.dataCaptureView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; this.captureOverlay = IdCaptureOverlay.Create(DataCaptureManager.Instance.IdCapture, this.dataCaptureView); this.captureOverlay.IdLayoutStyle = IdLayoutStyle.Square; this.View.AddSubview(this.dataCaptureView); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.SetContentView(Resource.Layout.activity_main); Toolbar toolbar = this.FindViewById <Toolbar>(Resource.Id.toolbar); this.SetSupportActionBar(toolbar); this.SupportActionBar.SetDisplayHomeAsUpEnabled(true); ViewGroup container = this.FindViewById <ViewGroup>(Resource.Id.data_capture_view_container); // Create a new DataCaptureView and fill the screen with it. DataCaptureView will show // the camera preview on the screen. Pass your DataCaptureContext to the DataCaptureView. this.view = DataCaptureView.Create(this, DataCaptureManager.Instance.DataCaptureContext); container.AddView(view, new Android.Widget.FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent)); this.overlay = IdCaptureOverlay.Create(DataCaptureManager.Instance.IdCapture, this.view); this.overlay.IdLayoutStyle = IdLayoutStyle.Square; }
private void Initialize() { // Create data capture context using your license key. dataCaptureContext = DataCaptureContext.ForLicenseKey(SCANDIT_LICENSE_KEY); // Use the recommended camera settings for the BarcodeTracking mode. var cameraSettings = BarcodeTracking.RecommendedCameraSettings; // Adjust camera settings - set Full HD resolution. cameraSettings.PreferredResolution = VideoResolution.FullHd; // Use the default camera and set it as the frame source of the context. // The camera is off by default and must be turned on to start streaming frames to the data // capture context for recognition. // See resumeFrameSource and pauseFrameSource below. camera = Camera.GetDefaultCamera(cameraSettings); if (camera == null) { throw new NullReferenceException( "Sample depends on a camera, which failed to initialize."); } dataCaptureContext.SetFrameSourceAsync(camera); // The barcode tracking process is configured through barcode tracking settings // which are then applied to the barcode tracking instance that manages barcode tracking. var barcodeTrackingSettings = BarcodeTrackingSettings.Create(); // The settings instance initially has all types of barcodes (symbologies) disabled. // For the purpose of this sample we enable a very generous set of symbologies. // In your own app ensure that you only enable the symbologies that your app requires // as every additional enabled symbology has an impact on processing times. var symbologies = new HashSet <Symbology> { Symbology.Ean13Upca, Symbology.Ean8, Symbology.Upce, Symbology.Code39, Symbology.Code128 }; barcodeTrackingSettings.EnableSymbologies(symbologies); // Create barcode tracking and attach to context. barcodeTracking = BarcodeTracking.Create(dataCaptureContext, barcodeTrackingSettings); // Register self as a listener to get informed of tracked barcodes. barcodeTracking.AddListener(this); // To visualize the on-going barcode tracking process on screen, setup a data capture view // that renders the camera preview. The view must be connected to the data capture context. var dataCaptureView = DataCaptureView.Create(this, dataCaptureContext); // Add a barcode tracking overlay to the data capture view to render the tracked barcodes on // top of the video preview. This is optional, but recommended for better visual feedback. var overlay = BarcodeTrackingBasicOverlay.Create(barcodeTracking, dataCaptureView); // Configure how barcodes are highlighted - apply default brush or create your own. // final Brush defaultBrush = new Brush(Color.BLUE, Color.RED, 5f); defaultBrush = overlay.Brush; overlay.Brush = defaultBrush; var rejectedFillColor = ContextCompat.GetColor(this, Resource.Color.barcode_rejected); var rejectedBorderColor = ContextCompat.GetColor(this, Resource.Color.barcode_rejected_border); rejectedBrush = new Brush(rejectedFillColor, rejectedBorderColor, 1f); overlay.Listener = this; // Add the DataCaptureView to the container. var container = FindViewById <FrameLayout>(Resource.Id.data_capture_view_container); container.AddView(dataCaptureView); }
private void InitializeAndStartBarcodeScanning() { // Create data capture context using your license key. this.dataCaptureContext = DataCaptureContext.ForLicenseKey(SCANDIT_LICENSE_KEY); // Use the default camera and set it as the frame source of the context. // The camera is off by default and must be turned on to start streaming frames to the data // capture context for recognition. // See resumeFrameSource and pauseFrameSource below. this.camera = Camera.GetDefaultCamera(); if (this.camera != null) { // Use the settings recommended by barcode capture. this.camera.ApplySettingsAsync(BarcodeCapture.RecommendedCameraSettings); this.dataCaptureContext.SetFrameSourceAsync(this.camera); } // The barcode capturing process is configured through barcode capture settings // which are then applied to the barcode capture instance that manages barcode recognition. BarcodeCaptureSettings barcodeCaptureSettings = BarcodeCaptureSettings.Create(); // The settings instance initially has all types of barcodes (symbologies) disabled. // For the purpose of this sample we enable a very generous set of symbologies. // In your own app ensure that you only enable the symbologies that your app requires as // every additional enabled symbology has an impact on processing times. HashSet <Symbology> symbologies = new HashSet <Symbology>(); symbologies.Add(Symbology.Ean13Upca); symbologies.Add(Symbology.Ean8); symbologies.Add(Symbology.Upce); symbologies.Add(Symbology.Qr); symbologies.Add(Symbology.DataMatrix); symbologies.Add(Symbology.Code39); symbologies.Add(Symbology.Code128); symbologies.Add(Symbology.InterleavedTwoOfFive); barcodeCaptureSettings.EnableSymbologies(symbologies); // Some linear/1d barcode symbologies allow you to encode variable-length data. // By default, the Scandit Data Capture 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 for one of the // variable-length symbologies. SymbologySettings symbologySettings = barcodeCaptureSettings.GetSymbologySettings(Symbology.Code39); ICollection <short> activeSymbolCounts = new HashSet <short>( new short[] { 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }); symbologySettings.ActiveSymbolCounts = activeSymbolCounts; // Create new barcode capture mode with the settings from above. this.barcodeCapture = BarcodeCapture.Create(this.dataCaptureContext, barcodeCaptureSettings); // Register self as a listener to get informed whenever a new barcode got recognized. barcodeCapture.AddListener(this); // To visualize the on-going barcode capturing process on screen, setup a data capture view // that renders the camera preview. The view must be connected to the data capture context. this.dataCaptureView = DataCaptureView.Create(this, this.dataCaptureContext); // Add a barcode capture overlay to the data capture view to render the location of captured // barcodes on top of the video preview. // This is optional, but recommended for better visual feedback. BarcodeCaptureOverlay overlay = BarcodeCaptureOverlay.Create(this.barcodeCapture, this.dataCaptureView); overlay.Viewfinder = RectangularViewfinder.Create(); SetContentView(this.dataCaptureView); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { this.dataCaptureView = DataCaptureView.Create(this.RequireContext(), null); return(this.dataCaptureView); }
protected void InitializeAndStartBarcodeScanning() { // Create data capture context using your license key. this.dataCaptureContext = DataCaptureContext.ForLicenseKey(SCANDIT_LICENSE_KEY); // Use the default camera and set it as the frame source of the context. // The camera is off by default and must be turned on to start streaming frames to the data // capture context for recognition. // See resumeFrameSource and pauseFrameSource below. this.camera = Camera.GetDefaultCamera(); if (this.camera != null) { // Use the settings recommended by barcode capture. this.camera.ApplySettingsAsync(BarcodeCapture.RecommendedCameraSettings); this.dataCaptureContext.SetFrameSourceAsync(this.camera); } BarcodeCaptureSettings barcodeCaptureSettings = BarcodeCaptureSettings.Create(); // The settings instance initially has all types of barcodes (symbologies) disabled. // For the purpose of this sample we enable a very generous set of symbologies. // In your own app ensure that you only enable the symbologies that your app requires as // every additional enabled symbology has an impact on processing times. HashSet <Symbology> symbologies = new HashSet <Symbology>() { Symbology.Ean13Upca, Symbology.Ean8, Symbology.Upce, Symbology.Qr, Symbology.DataMatrix, Symbology.Code39, Symbology.Code128, Symbology.InterleavedTwoOfFive }; barcodeCaptureSettings.EnableSymbologies(symbologies); // Some linear/1d barcode symbologies allow you to encode variable-length data. // By default, the Scandit Data Capture 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 for one of the // variable-length symbologies. SymbologySettings symbologySettings = barcodeCaptureSettings.GetSymbologySettings(Symbology.Code39); HashSet <short> activeSymbolCounts = new HashSet <short>( new short[] { 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }); symbologySettings.ActiveSymbolCounts = activeSymbolCounts; // Create new barcode capture mode with the settings from above. this.barcodeCapture = BarcodeCapture.Create(this.dataCaptureContext, barcodeCaptureSettings); // Register self as a listener to get informed whenever a new barcode got recognized. this.barcodeCapture.AddListener(this); // To visualize the on-going barcode capturing process on screen, setup a data capture view // that renders the camera preview. The view must be connected to the data capture context. this.dataCaptureView = DataCaptureView.Create(this.dataCaptureContext, this.View.Bounds); this.dataCaptureView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; this.View.AddSubview(this.dataCaptureView); this.overlay = BarcodeCaptureOverlay.Create(this.barcodeCapture, this.dataCaptureView); this.overlay.Viewfinder = RectangularViewfinder.Create(RectangularViewfinderStyle.Square, RectangularViewfinderLineStyle.Light); // Adjust the overlay's barcode highlighting to match the new viewfinder styles and improve the visibility of feedback. // With 6.10 we will introduce this visual treatment as a new style for the overlay. overlay.Brush = new Brush(fillColor: UIColor.Clear, strokeColor: UIColor.White, strokeWidth: 3); this.dataCaptureView.AddOverlay(this.overlay); }