Get Started
In this guide you will learn step-by-step how to add MatrixScan Count to your application.
The general steps are:
- Create a new Data Capture Context instance
- Configure the Barcode Count Mode
- Obtain camera instance and set frame source used
- Register the listener to be informed when scanned phase is over
- Set capture view and AR overlays
- Set up the camera so that it switches on when you are in scanning view
- Store and retrieve scanned barcodes
- Reset Barcode Count mode
- List and Exit callbacks
Create A New Data Capture Context Instance
The first step to add capture capabilities to your application is to create a new Data Capture Context. The context expects a valid Scandit Data Capture SDK license key during construction.
var dataCaptureContext = DataCaptureContext.forLicenseKey('-- ENTER YOUR SCANDIT LICENSE KEY HERE --');
Configure The Barcode Count Mode
The main entry point for the Barcode Count Mode is the BarcodeCount object. It is configured through BarcodeCountSettings and allows you to register one or more listeners that are informed whenever a scan phase has finished.
For this tutorial, we will set up Barcode Count for tracking EAN13 codes. Change this to the correct symbologies for your use case (for example, Code 128, Code 39…).
var settings = new BarcodeCountSettings();
settings.enableSymbology(Symbology.ean13Upca, true);
If you are sure that your environment will only have unique barcodes (i.e. no duplicated values), you can also enable BarcodeCountSettings.expectsOnlyUniqueBarcodes. This option improves scanning performance as long as you are sure that no duplicates will be present. Next, create a BarcodeCount instance with the Data Capture Context and the settings initialized in the previous step:
var barcodeCount = BarcodeCount.forContext(dataCaptureContext, settings);
Obtain Camera Instance And Set Frame Source Used
Our recommended camera settings should be used to achieve the best performance and user experience. The following couple of lines show how to get the recommended settings for MatrixScan Count and create the camera from it:
Because the frame source is configurable, the data capture context must be told which frame source to use. This is done with a call to DataCaptureContext.setFrameSource():
dataCaptureContext.setFrameSource(camera);
Register the Listener
To keep track of the barcodes that have been scanned, implement the BarcodeCountListener interface and register the listener.
barcodeCount.addListener(this);
BarcodeCountListener.didScan() is called when the scan phase has finished and results can be retrieved from BarcodeCountSession.
Set Capture View And AR Overlays
MatrixScan Count’s built-in AR user interface includes buttons and overlays that guide the user through the capturing process. By adding a BarcodeCountView the scanning interface (camera preview and scanning UI elements) will be added automatically to your application.
Add a BarcodeCountView to your view hierarchy:
var barcodeCountView = BarcodeCountView.forContextWithMode(dataCaptureContext, barcodeCount);