Welcome!

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

Reply
Trusted Contributor
KJake
Posts: 202
Registered: ‎11-21-2010
My Device: 9700
My Carrier: Virgin Mobile

Re: ZXING Barcode Scanning API for OS 5.0

Thanks for the reply.  I cannot seem to locate

 

import net.rim.device.api.barcodelib.BarcodeDecoder;

import net.rim.device.api.barcodelib.BarcodeDecoderListener;

import net.rim.device.api.barcodelib.BarcodeScanner;

 

Are these substituted with something else or available somewhere under OS 5?

 

Do you find that the same OS 5 code works equally well under OS 6 as well?

 

Please use plain text.
New Contributor
zhnupy
Posts: 4
Registered: ‎03-08-2011
My Device: 9300,9700
My Carrier: Telcel

Re: ZXING Barcode Scanning API for OS 5.0

nop, in OS 5.0 I started with the sample app included with zxing (the rim client) regards
Please use plain text.
Contributor
specific
Posts: 31
Registered: ‎01-27-2011
My Device: Tablet

Re: ZXING Barcode Scanning API for OS 5.0

Hi all,

 

I m using Zxing Barcode reader and its  working for QR code but i want to use it for 1D barcode reader for BB 5.0. i have tried to change watever i read in this thread but its not working for 1D.

 

Can any one of please help me to got solution becoz i have to deliver soon so now no more time to R & D. please give me code if possible.

dont mind my english

 

 

Thanks 

Manish

 

Please use plain text.
Visitor
gjcamacho
Posts: 1
Registered: ‎04-04-2011
My Device: BlackBerry 9330
My Carrier: Iusacell

Re: ZXING Barcode Scanning API for OS 5.0

Hello!

 

Thanks Ezequiel!

 

Does this post work on OS 5?

 

Thanks!

 

Gerardo

Please use plain text.
Regular Contributor
anawara
Posts: 64
Registered: ‎04-27-2010
My Device: Bold 9000
My Carrier: Vodafone

Re: ZXING Barcode Scanning API for OS 5.0

One problem with using the ZXING library the way that Google illustrates in the ZXingUiApplication example is that the user has to take a picture of the barcode using the camera application. Sometimes the captured picture isn't decoded correctly. In this case the user would have to take another picture and another until it actually works.

 

I've created a work around for this issue. Instead of invoking the camera application like the example says, I create a screen with a VideoControl element on it and set it to full screen with a resolution of 640x480. I then start a separate thread that takes a snapshot of the display using Display.screenshott() every three seconds and try to decode the barcode. I keep doing that until there's been a successful decoded barcode image or the user hits back,.

 

The reason I used the Display.screenshot() method is because when I used the _videoControl.getSnapShot() method the phone would pause for a second and would play the camera shutter sound which kinda took away from the effect of the scanner. However, with Display.screenshot, it doesn't play such sound effects.

 

So these are the steps:

 

  1. create a screen with a VideoControl set to full screen mode and specify the resolution along with the encoding to jpeg
  2. Spawn a thread that calls Display.screenshot() every three seconds
  3. Send the screenshot Bitmap to the decoding method (In my case I used the same steps as the example. However, I did create my own LCDUIBitmapLuminanceSource that uses RIMs implementation of Bitmaps rather than the Java ME Image)
  4. If the bitmap is decoded correctly, then notify a listener of the success and the content of the QR code

This worked with OS 4.6 and 5.0. I don't see why it wouldn't work with OS 4.5. Hope this helps

 

Please use plain text.
Regular Contributor
meanman
Posts: 61
Registered: ‎08-25-2010
My Device: Torch 9800
My Carrier: O2

Re: ZXING Barcode Scanning API for OS 5.0

Thank you to everybody's contribution on this matter.

 

Just having some conformation of other's having it working is great to work with. So I have managed to get it working as well for a client:

 

Here is my two cents:

- Don't use the TRY_HARDER flag.

- Implement your own LuminanceSource effectively using a BlackBerry Bitmap instead of J2ME image.

- Don't use the BlackBerry sample provided - it's no use. Instead use the J2ME sample from the source and modify to suit needs. It has support for camera focus etc, which is really useful for OS 5. Use preprocessing where necessary.

- As above spawn a thread to capture a screenshot to bitmap every couple of seconds and then process that.

- Instead of trying to get everything done at once, first write code that loads an easy to decode QR code from a Bitmap and then test the QR decoding capabilities. Then write the camera/screenshot code.

 

Please use plain text.
bog
Contributor
bog
Posts: 35
Registered: ‎05-11-2011
My Device: 9800
My Carrier: bell

Re: ZXING Barcode Scanning API for OS 5.0

how do you guys use zxing to detect qr code in camera images?

 

I can only getsnapshot from camera, but the input of qr code detector is bitmatrix, anyone know how to convert bitmap/byte array  to bitmatrix? 

Please use plain text.
Regular Contributor
meanman
Posts: 61
Registered: ‎08-25-2010
My Device: Torch 9800
My Carrier: O2

Re: ZXING Barcode Scanning API for OS 5.0

You shouldn't have to - just implement a BitmapLuminanceSource instead of ImageLuminanceSource - it really is straightforward.

 

Instead of a camera snapshot I take a screenshot as it is faster and does not produce a "snapshot" sound.

 

 

Please use plain text.
bog
Contributor
bog
Posts: 35
Registered: ‎05-11-2011
My Device: 9800
My Carrier: bell

Re: ZXING Barcode Scanning API for OS 5.0

Thanks for your advise, that really helps.

 

Regards,

 

Bo

Please use plain text.
Contributor
ali_irawan
Posts: 14
Registered: ‎05-18-2011
My Device: 9300, 9700
My Carrier: T-Mobile

Re: ZXING Barcode Scanning API for OS 5.0

I'm having this issue as well. Because in the OS 5.0, there's no built-in barcode lib API just like in 6.0

Then I do some research, how to implement the barcode scanner in 5.0

 

Combining using VideoPlayer using the View Finder. (see this post)

It really helps. Then I try to create my own class.

 

I create class in my project

 

BarcodeDecoder.java

BarcodeDecoderListener.java (interface)

BarcodeScanner.java

BitmapLuminanceSource.java

 

The class name is similar to class name in the built-in barcode API in 6.0. But I should implements the method by myself.

The BarcodeDecoder is hold the Hashtable for readerHints. The listener method is invoked when the Code has already been decoded.

BarcodeScanner is holding the Player, VideoControl, and ViewFinder

 

The usage is:

 

if (_camera == null) {
    _camera = new ViewFinderScreen(
                _contentBarcodeScanner._barcodeText);
}
UiApplication.getUiApplication().pushScreen(camera);
_camera.startScan();

 

So simple, but I only have tested with QR Code, and it works fine. Have not been tested with other Barcode format. After struggling with myself in a day, finally I can accomply this to make my own classes with Java code to perform similar function as barcodelib in OS 6.0. I have just only test for OS 5.0, with device 9300.

 

In decoding I'm using

 

final byte[] imageBytes = _vc.getSnapshot(_encoding);

....

// create image from bytes
Bitmap capturedBitmap = Bitmap.createBitmapFromBytes(imageBytes, 0,
 		imageBytes.length, 1);


MultiFormatReader reader = new MultiFormatReader();

LuminanceSource source = new BitmapLuminanceSource(capturedBitmap);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));

//not the hints must be set using Hashtable
//please see zxing documentation/wiki to use reader hints

result = reader.decode(bitmap, hints);
rawText = result.getText();

 

Hope this helps. If anyone want to ask more detail on this. Feel free to contact me. Thanks for the thread. It really helps me.

Until you spread your wings, You will have no idea how far you can fly
Please use plain text.