ZXing on Android - High Decoding Performance

As the name suggests, I am trying to decode QR codes on an Android device using the ZXing Barcode Scanner app. I read several threads on the internet about how it is not recommended to integrate an application into one own project. Should be used instead IntentIntegrator

.

However, this is not an option in my case. Below is the code snippet I am calling for each 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 5 to 8 seconds.

I have tried using both MultiFormatReader

and QRCodeReader

.

Can anyone shed some light on this topic?

+3


source to share


4 answers


It turns out that performance is highly dependent on the Android debugger attached to the app. The approximate time to scan a full camera image on HTC Desire HD takes about 150 ms - 200 ms. Stupid mistake on my part.



+5


source


I only use ZXing with intent and it's very fast, so to throw the idea here: maybe the input image is too big - maybe reduce the size before throwing it into the decoder.



+1


source


This is why you want to crawl the intent - no coding or debugging, and you crawl optimally.

Here, I assume you are feeding it a full 5MP image or whatever. Do not do that.

+1


source


The decoding performance will also depend on the speed of your phone. For a given phone / tablet, performance will not increase beyond a certain point because this library is running on ARM / ACPU.

You may need to work on optimizing your application. In addition, you can:

  • Use the washing method so that the flows are different.

  • Try to feed the image at a low resolution, so image processing does not take up much space.

  • Maintain an even tilt or try to keep a parallel plane between the phone and the barcode sticker / printed page.

0


source







All Articles