03-27-2011 09:52 AM
Thanks for the reply. I cannot seem to locate
import net.rim.device.api.barcodelib.BarcodeDecoder;
import net.rim.device.api.barcodelib.BarcodeDecoderListen
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?
03-27-2011 02:57 PM
03-28-2011 05:52 AM
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
04-04-2011 07:18 PM
Hello!
Thanks Ezequiel!
Does this post work on OS 5?
Thanks!
Gerardo
04-09-2011 01:42 PM
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:
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
04-20-2011 11:01 AM
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.
05-17-2011 06:13 PM
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?
05-18-2011 02:32 AM
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.
05-19-2011 07:01 PM
Thanks for your advise, that really helps.
Regards,
Bo
05-20-2011 10:14 PM
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.