Get Started
In this guide you will learn step-by-step how to add MatrixScan AR to your application. Implementing MatrixScan AR involves two primary elements:
- Barcode AR: The data capture mode that is used for scan and check functionality.
- A Barcode AR View: The pre-built UI elements used to highlight items to be checked.
The general steps are:
- Creating a new Data Capture Context instance
- Configuring the Barcode AR Mode
- Setup the Barcode AR View
- Registering the Listener to notify about found items
Prerequisites
Before starting with adding a capture mode, make sure that you have a valid Scandit Data Capture SDK license key and that you added the necessary dependencies. If you have not done that yet, check out this guide.
You can retrieve your Scandit Data Capture SDK license key by signing in to your account Dashboard.
Internal Dependencies
Some of the Scandit Data Capture SDK modules depend on others to work:
Module | Dependencies | Optional Dependencies |
---|---|---|
ScanditCaptureCore | None | None |
ScanditBarcodeCapture | ScanditCaptureCore | None |
ScanditParser | None | None |
ScanditLabelCapture | ScanditCaptureCore ScanditBarcodeCapture | ScanditLabelCaptureText ScanditPriceLabel |
ScanditIdCapture | ScanditCaptureCore | ScanditIdCaptureBackend ScanditIdEuropeDrivingLicense ScanditIdAamvaBarcodeVerification ScanditIdVoidedDetection |
When using ID Capture or Label Capture, consult the respective module's getting started guides to identify the optional dependencies required for your use case. The modules you need to include will vary based on the features you intend to use.
Please be aware that your license may only cover a subset of Barcode and/or ID Capture features. If you require additional features, contact us.
Create a Data Capture Context
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.
DataCaptureContext dataCaptureContext = DataCaptureContext.ForLicenseKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --");
Configure the Barcode AR Mode
The main entry point for the Barcode AR Mode is the BarcodeAr
object. You can configure the supported Symbologies through its BarcodeArSettings
.
Here we configure it for tracking EAN13 codes, but you should change this to the correct symbologies for your use case.
BarcodeArSettings settings = new BarcodeArSettings();
settings.SetSymbologyEnabled(Symbology.EAN13_UPCA, true);
Then create the mode with the previously created settings:
BarcodeAr mode = new BarcodeAr(dataCaptureContext, settings);
Setup the BarcodeArView
MatrixScan AR’s built-in AR user interface includes buttons and overlays that guide the user through the scan and check process. By adding a BarcodeArView
, the scanning interface is added automatically to your application.
The BarcodeArView
is where you provide the highlightProvider
and/or annotationProvider
to supply the highlight and annotation information for the barcodes to be checked. If null, a default highlight is used and no annotations are provided.
The BarcodeArView
appearance can be customized through BarcodeArViewSettings
, properties on theBarcodeArView
, and the corresponding settings for your desired highlights and/or annotations, to match your application’s look and feel. The following settings can be customized:
- Audio and haptic feedback
- Camera position
- Torch button visibility and its position
- Switch camera button visibility and its position
- Zoom control visibility and its position
- The size, colors, and styles of the highlights and annotations
BarcodeArViewSettings viewSettings = new BarcodeArViewSettings();
viewSettings.HapticEnabled(false);
viewSettings.SoundEnabled(false);
viewSettings.DefaultCameraPosition(CameraPosition.USER_FACING);
Next, create a BarcodeArView
instance with the Data Capture Context and the settings initialized in the previous step. The BarcodeArView
is automatically added to the provided parent view.
BarcodeArView barcodeArView = BarcodeArView(parentView, barcodeAr, dataCaptureContext, viewSettings);
barcodeArView.ShouldShowCameraSwitchControl(true);
barcodeArView.ShouldShowTorchControl(true);
barcodeArView.ShouldShowZoomControl(true);
barcodeArView.CameraSwitchControlPosition(Anchor.TOP_RIGHT);
barcodeArView.TorchControlPosition(Anchor.BOTTOM_RIGHT);
barcodeArView.ZoomControlPosition(Anchor.TOP_LEFT);
Configure the highlightProvider
and/or annotationProvider
.
public class AnnotationProvider : BarcodeArAnnotationProvider
{
public void AnnotationForBarcode(Context context, Barcode barcode, ICallback callback)
{
var annotation = new BarcodeArStatusIconAnnotation(context, barcode);
annotation.Text = "Example annotation";
callback.OnData(annotation);
}
}
public class HighlightProvider : BarcodeArHighlightProvider
{
public void HighlightForBarcode(Context context, Barcode barcode, ICallback callback)
{
callback.OnData(new BarcodeArRectangleHighlight(context, barcode));
}
}
And set them to the view:
barcodeArView.HighlightProvider(new HighlightProvider());
barcodeArView.AnnotationProvider(new AnnotationProvider());
Register the Listener
If you want a callback when a highlight is tapped, register a BarcodeArViewUiListener.
barcodeArView.SetUiListener(new BarcodeArViewUiListener());
public class BarcodeArViewUiListener : BarcodeArViewUiListener
{
public void OnHighlightForBarcodeTapped(BarcodeAr barcodeAr, Barcode barcode, BarcodeArHighlight highlight, View highlightView)
{
// Handle tap
}
}
Start Searching
With everything configured, you can now start searching for items. This is done by calling:
barcodeArView.Start();