Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 190
Registered: ‎07-08-2009
My Device: Not Specified

Issues in scanning Aztec barcodes



We have tried 2 approaches for BarCode Scanning (Aztec Codes).


Approach 1 :

First we attempted to use the sample provided here. We were able to scan various types of Barcodes (QR, EAN13 etc) successfully but we didn’t find an option for scanning Aztec barcodes.

Then we tried to use BarCodeScanner class separately but could not since its constructor indirectly makes use of BarcodeFormat class (RIM Internal) for specifying which kind of Barcode to decode and BarcodeFormat class doesn’t contain an option for Aztec bar codes.



Approach 2:

Next we had to resort to using ZXing (Google provided) library directly.


1)       For Barcode scanning we are making use of ZXing library provided by Google.

2)       The ZXing library provides Barcode scanning implementation for Blackberry also, but in that it is done by manually capturing image and then processing it.

3)       Since we require to scan barcode from live video feed we changed our code accordingly :


// Create a player for the Blackberry's camera

             Player player= Manager.createPlayer("capture://video?encoding=jpeg&width=1280&height=1024&quality=normal");


             // Set the player to the REALIZED state (see Player javadoc)



            // Grab the video control and set it to the current display

            _videoControl = (VideoControl)player.getControl( "VideoControl" );


             if (_videoControl != null)


              // Create the video field as a GUI primitive (as opposed to a

              // direct video, which can only be used on platforms with

              // LCDUI support.)

              _videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE,                                                          "net.rim.device.api.ui.Field");



              if(_videoField != null)




          // Set the player to the STARTED state



4)       For scanning the Barcode we are taking snapshot of live video feed every 2 seconds and processing the image obtained in a separate background thread.


Bitmap image = new Bitmap(Display.getWidth(),Display.getHeight());


            Runnable fct = new FileConnectionThread(image);



      Here FileConnectionThread decodes the image in a separate background thread.


Issues faced in approach 2 :

1) The video feed that we are getting from step 3 is not of good quality and so the snapshot obtained is also of not good quality and hence the image could not be successfully decoded.

2) We could not find any arguments to enhance video quality of live feed of camera. We tried to change values of parameters ‘width=1280&height=1024&quality=normal’ to different values but it had no effect on quality.

3) We were successful in decoding some Aztec barcodes (codes with less data and bigger in size) with our approach but failed to decode barcodes with larger information. 

4) We also tried to make use of  _videoControl.getSnapshot(null) instead ofDisplay.screenshot(image)but using this  way it pauses every time it takes snapshot thereby making processing of image much slower.


We searched on internet if we can use camera as it is used in Blackberry Messenger for scanning barcodes. In Blackberry messenger video feed is very clear. But we could not find any way to use camera that way either.


Is there any way so as to scan Aztec Barcodes effectively?


Any pointers in this regard will be appreciated.


Thanx in advance,



Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Issues in scanning Aztec barcodes

The Aztec format wasn't supported in the version of ZXing we included with 6.0 or 7.0. I believe even in the current version it only has alpha level support.


If you would like to scan the Aztec format, or any other one we don't support, the best way to do it would be to use theImageScanner class to create your own decoder. This ability was included in 7.0.


ImageScanner requires an ImageDecoder. It passes the camera preview frames to the ImageDecoder, which is  an interface with a single method, “decode”. 


You can use this to write a scanner for any barcode format you like. You could also use it with your second approach to get a proper image.

Paul Bernhardt
Application Development Consultant

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Posts: 190
Registered: ‎07-08-2009
My Device: Not Specified

Re: Issues in scanning Aztec barcodes

[ Edited ]