Mobile Development 10.11 | webMethods Mobile SuiteWeb Help | Using webMethods Mobile Designer | Creating Mobile Application Projects | Coding a Mobile Application | Migrating to the New Run-Time Classes | Using the ImagePicker Class | Capturing Barcodes Using ImagePicker | Live Barcode Scanning
 
Live Barcode Scanning
When scanning a barcode directly from live video feed, there are a few extra considerations. The live scanning methods also take a frame rate in their arguments. Devices pick a value that can be supported by the hardware that most closely matches your required frame rate. The frame rate should be carefully chosen. If the value is too high, this can cause the device to work too hard, draining the battery and slowing down the UI. Similarly, if the frame rate is too slow, it gives a poor experience for the user.
Tip:
Most handsets perform well with an update rate somewhere between 15-20fps.
When scanning live video, your IBarcodePickerCallback must also implement wouldAcceptBarcode(). For each frame in which valid barcodes are detected, the callback is asked if this frame's barcodes should stop the scanning process. Code in wouldAcceptBarcode() must be as performant as possible, and must make no changes to the application state. The onBarcode() method is called as normal after wouldAcceptBarcode() signalled that the barcodes have been accepted.
public boolean wouldAcceptBarcode(String[] barcodes)
{
if(barcodes != null && barcodes.length > 0)
{
for(int i = 0; i < barcodes.length; i++)
{
if(barcodes[i] != null && barcodes[i].startsWith("2345"))
{
return true; //This is our product, handle actions in onBarcode()
}
}
}
return false; //reject barcodes, keep scanning
}