Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ZXing on Android - Decode performance extremely slow

As the title suggests, I am trying to decode QR codes on an Android device using ZXing's Barcode Scanner app. I have read multiple threads on the internet about how it is discouraged to integrate the app within one's own project. Instead, one should use IntentIntegrator.

However, this is not an option in my case. Below is a snippet of code which I am calling for every camera frame.

LuminanceSource source = new RGBLuminanceSource(bitmap);
BinaryBitmap bm = new BinaryBitmap(new HybridBinarizer(source));

try {
    Result result = reader.decode(bm); // This line takes approx. 6seconds
    if (!result.getText().isEmpty()) {
        Log.e("MYTAG", "Found something: "+result.getText());
    }
}
catch (NotFoundException e) {
    e.printStackTrace();
} catch (ChecksumException e) {
    e.printStackTrace();
} catch (FormatException e) {
    e.printStackTrace();
}

As I said, this process is extremely slow. Decoding takes anywhere between 5 to 8 seconds.

I have tried using both the MultiFormatReader and the QRCodeReader.

Can anyone shed some light on the subject?

like image 200
justin.saliba Avatar asked Dec 22 '22 00:12

justin.saliba


1 Answers

Turns out that the performance suffers greatly with the Android debugger attached to the application. Approximate time taken to scan a full camera frame image on an HTC Desire HD takes around 150ms - 200ms. Silly mistake on my part.

like image 97
justin.saliba Avatar answered Dec 27 '22 11:12

justin.saliba