Deprecation warning

Please note that this is outdated documentation for an older release of the Scandit Barcode Scanner SDK.

We encourage you to migrate to 6.x and take advantage of our latest / advanced features and improved performance.

You'll find the updated documentation at: Data Capture SDK Documentation for Android

Batch Mode Scanning/Barcode Selection

Motivation

The default scan mode provided by the Scandit Barcode Scanner searches barcodes/2d codes in the whole image. This works well when scanning individual codes. However, when scanning codes from sheets with a large number of densely packed barcodes, the full screen scan mode is not optimal as there is little control for the user to decide which code is going to get scanned. With very little code it is possible to implement mechanisms that help selecting the code to be scanned.

Two such "barcode selection modes" have been implemented in the BatchScanSample which is included in the Android SDK.

Aim and Scan

In the first of the two modes, the camera is started with the barcode scanner in paused state. After positioning the phone such that the barcode is in the center of the image, the user presses the "Scan barcode" button to activate the barcode scanner and scan the code.

Steps

To implement the Aim and Scan mode in your application, you will need to do the following:

  • 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.setRestrictedAreaScanningEnabled(true);
settings.setScanningHotSpotHeight(0.05f);
  • Modify the GUI style to have a "laser" line instead of a square view finder and the scan button to the view
//Set laser gui and add button
mBarcodePicker.getOverlayView().setGuiStyle(ScanOverlay.GUI_STYLE_LASER);
buttonScan = new Button(this);
buttonScan.setTextColor(Color.WHITE);
buttonScan.setTextColor(Color.WHITE);
buttonScan.setTextSize(20);
buttonScan.setGravity(Gravity.CENTER);
buttonScan.setText("Scan barcode");
buttonScan.setBackgroundColor(0xFF39C1CC);
addScanButton();
buttonScan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resumeScanning();
}
});
  • Resume scanning in scan button action
mBarcodePicker.resumeScanning();
  • Pause the scanner when a barcode is detected, show the value decoded and set the user interface to “stop mode”
public void didScanBarcode(String barcode, String symbology) {
session.pauseScanning();
session.clear();
Toast.makeText(this, symbology + ": " + barcode, Toast.LENGTH_LONG).show();
laserScan.setBackgroundColor(Color.BLUE);
}

Scan and Confirm

In this selection mode, the camera is started and the scanner activated to scan codes. When a code is scanned a confirm dialog is shown where the user can tap confirm when the correct code has been scanned.

Steps

To implement the Scan and Confirm mode in your application, you will need to do the following:

  • Enable and set the restrict active area
mBarcodePicker.getOverlayView().setViewfinderDimension(0.7f, 0.05f, 0.7f, 0.05f);
  • Modify the GUI style to have a "laser" line instead of a square view finder
mBarcodePicker.getOverlayView().setGuiStyle(ScanOverlay.GUI_STYLE_LASER);
  • Start the scanning
mBarcodePicker.startScanning();
  • Show the last barcode scanned on the screen
public void didScanBarcode(String barcode, String symbology) {
Toast.makeText(this, symbology + ": " + barcode, Toast.LENGTH_LONG).show();
}