Scanning Raw Image Data

If you need to customize barcode scanning even further, the Barcode SDK also provides the ability to scan raw image data for barcodes. This is the most advanced use of barcode scanning on the device. The developer will be responsible for both acquiring and pre-processing image data before handing off to the barcode scanner. Before barcodes can be scanned, the scanner needs to be initialized with a context:

Java

import com.vuzix.sdk.barcode.Scanner2; import com.vuzix.sdk.barcode.ScanResult2; import com.vuzix.sdk.barcode.Scanner2Factory; Scanner2 scanner = Scanner2Factory.getScanner(context);


You can then scan your raw image data for barcodes. The byte array data you scan should be grayscale image data. You’ll also need to provide the width and height of the image data. For example:

Java

// acquire image data byte[] data; int width; int height; Rect rect = null; // scan image data ScanResult2[] results = scanner.scan(data, width, height, rect); If (results.length > 0) { // we got results, do something with them }


For more information on scanning raw image data for barcodes, including the various options available, refer to the Java Doc for the Scanner class.

A sample Android Studio project demonstrating barcode scanning via raw image data is available to download here.

Did this answer your question?