Scanning Raw Image Data
  • 05 Sep 2024
  • 1 Minute to read
  • Contributors
  • Dark
    Light

Scanning Raw Image Data

  • Dark
    Light

Article summary

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:

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:

// 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 JavaDoc for the Scanner class.

A sample Android Studio project demonstrating barcode scanning via raw image data is available on our Github.


Was this article helpful?