Friday, April 29, 2011

Zbar on Android with the NDK

We've had experience writing an automobile VIN (Code 39) scanner on both iPhone and Android. In the case of the iPhone we leverage the ZBar library and the Android the ZXing library. Unfortunately, Android has been a tremendous amount of work. There was a tremendous amount of fracturing with the camera drivers to code around to tune the image capture. But that's another story...

For the image processing the ZXing library on Android with was simply not as fast or accurate as capturing   Code 39 barcodes (no opinion on QR, etc.) as ZBar on the iPhone. This left an interesting customer service dilemma as Android would be subpar. We looked at a few options and settled on an interesting proposition.

Android recently introduced the NDK (Native Development Kit) that allows you to build native code from C/C++. Interesting... We realized that there was a good chance that we could get the ZBar library running on Android with the NDK (at least for the image processing). We did have to rewrite the build/make system as the NDK does not have full make/configure support. But, after investing time in this we were able to build the ZBar library on the NDK and leverage their JNI wrapper to invoke this code on Android.

So far the results have been excellent. The ZBar library on Android is 50% faster in recognition for Code 39 and a lot more accurate.

We'll be donating an example project to the ZBar project once we can remove the client specific portions.

Also, just be aware this only applies for Code 39. We have no idea how the image processing quality compares for the other formats.

5 comments:

  1. I have been wanted to write a Bar Code scanner app for iPhone. I want to pick your brain sometime next week. Beers after work?

    ReplyDelete
  2. Hello dear,
    I have been using google zxing for real time barcode and qr code detection., but as u said using zbar will improve it over 50% better., could please elaborate your process for using zbar on android

    thanx in advance

    ReplyDelete
  3. I need to read Code 128 barcode, but I am not able to read it using ZXing with some Android devices and even iPhone 4. However, the same is read perfectly fine and quick with the ZBar iPhone App. I need to be able to use the ZBar library on both iPhone and Android. Can you help me with the ZBar Android library with the JNI wrapper that you have written?

    Thanks!

    ReplyDelete
  4. Hey,

    Did you end up creating an example project without the client specific code? I would love to see it.

    -Jared

    ReplyDelete
  5. Unfortunately, like most things in life, hadn't had time to put together a sample without the client code as of yet.

    ReplyDelete