03-08-2011 04:23 AM
Thanks Diego, very useful information. it works nicely in devices with autofocus capability.
I wonder if you encounter problems when using TRY_HARDER hint, the rotation code throws an exception every time. This exception happens in both LCDUIImageLuminanceSource and my Bitmap-based version, the logic seems right however.
The exception always occurs while grabbing a row: bitmap.getARGB(....
strangely it is a IllegalArgumentException, which is not documented to be thrown by that Bitmap's method:
public void getARGB(int argbData,int offset,int scanLength,int x,int y,int width,int height)
The exception is thrown when the method is called for the row 1024th (which correspond to column 1024th in original bitmap), as if the bitmap wasn't big enough, but the dimensions returned by bitmap.getWidth() and bitmap.getHeight are correct. In my case I'm using images 2048x1536.
Did someone else found same issue?
03-09-2011 02:09 AM
The post was really helpful, and was able to implement the barcode scanner for OS pre 4.5 devices as well.
I tried using the application on BlackBerry 8320 (v4.2.2), the procedure involved is:
1. On clicking "Snap" the camera gets invoked, I need to CAPTURE the image.
2. After the image is captured, it gets saved, and this image is read.
3. If a QR Code is found, the result is shown.
Can we not Identify if there is a QR Code available in the image before capturing it, like its done on 6.0 or Android? Issue I'm facing is if the image that I capture is not good, say if its blurred or some part is cut, the image cannot be decoded, so I'll have to capture the image again. So instead of that, image should be captured only if it can detect a QR Code! Is that possible? If yes, can someone give me some pointers as to how I need to proceed?
Or is it something to do with the Auto-Focus capability of the phone, which my phone (8320) apparently does not have?
Any help is regard would be greatly appreciated.
03-09-2011 02:55 PM
I have the same problem. I'm trying to let ZXing qr reader working in
platform 4.5, but still no success. I'm having an ArithmethicException while decoding.
I downloaded the BarcodeReder and added the packages rim, j2me and core
from ZXing projects, as source code for now, to avoid having to package
.jar files inside the cod file.
About reading and recognizing qr before capturing is difficult to do in os
versions prior to 4.6 since there's no way to control the camera from the
application, only thing to do is to launch the built-in camera
application, but that's need some user interaction to take the photo and
listening to file system to read the newly captured image as a file.
I've read about a workaround to control camera in os 4.5 and earlier, and
it's called "event injection" or so, but it is not recomended. The idea is
something like taking pictures repeteadly from our app injecting events in
the built-in camera application until a valid qr image file is detected in
file system. I have never tried it.
Since os 4.6 it is possible to control the video camera using platform's
api and using a view field to show the image continuously inside our app screen instead of having to call the built-in camera application in the os.
Hope this helps and if someone else has some other suggestions for reading
qr in os 4.5, they will be very welcome.
03-15-2011 04:15 PM
This is the best thread I've seen on BB & Zxing.
Has anyone managed to scan Aztec barcodes? I managed to do it using the latest Zxing library by taking a picture of the barcode. By I would like to do it with continuous scanning using the video camera. So I am trying to combine the OS 6.0 BarcodeLibrary with the latest Zxing library.
Has anyone tried to replaced the com.google.Zxing on the BB device by one compiled from the latest Zxing code? Any other suggestions?
Any suggestions would be appreciated.
03-16-2011 10:08 AM
Not sure if that's possible, I think that it is not. You may not be able to replace platform's libraries or give some more priority to your jars instead of os's included libraries if they have the same package name.
Everything what I can tell you is just to download the last version (or the one you like) and change the package name in the source code to avoid conflicting with BB 6.0 OS ZXing included libraries. You could add a package suffix sth like "mypackage.extlib.com.google.zxing.*" and use those classes instead of OS 6.0.
A better solution is also welcome.
03-16-2011 11:03 AM
Thanks for the feedback Ezequiel.
Here is a more detailed description of the situation.
My understanding is that the net_rim_barcodelib.cod library contains several packages, including com.google.zxing, net.rim.device.api.barcodelib.
The first package (and its derivatives) come from the Zxing open source project. It handles the coding and decoding of barcodes.
The net.rim.device.api.barcodelib contains classes developed by RIM to control (Start/Stop) the scanner, along with the barcodeDecoded event . This package uses the classes in the com.google.zxing package.
At the time OS 6.0 was released, the com.google.zxing did not support Aztec. So RIM's OS 6.0 did not support Aztec barcode decoding either.
In its latest version, the Zxing supports Aztec barcodes, which I am trying to integrate in my application. I would also like to use the scanning based on video, rather than capturing images and scanning them.
I am looking at one of 3 options:
1. Replace the com.google.zxing that is in OS 6.0 by the new one that supports Aztec. This way the classes in net.rim.device.api.barcodelib will use the new Zxing library and hence will have the ability to decode Aztec barcodes. That does not seem to be possible, as RIM physically put both packages in the same .cod. (Althought the library has actually 2 .cod files, namely net_rim_barcodelib.cod & net_rim_barcodelib-1.cod).
2. Rewrite the equivalent of the net.rim.device.api.barcodelib classes using the new Zxing library. I am not really sure if this is at all feasible - especially barcode scanning from video feed - since RIM could have used internal APIs not available to external developers.
3. Wait till RIM comes up with a new version of the OS that supports Aztec. No idea when that will be.
So, currently I am at an impass. Any insight from RIM and other BlackBerry developers would be highly appreciated.
03-25-2011 02:33 PM
Mitchel, I'm developing for BB OS 5 and since I have little time,I could not research some more about it.
I agree with you that option 1 is most likely impossible.
It's true you'll have some more work than expected, you'll have to rewrite (or maybe just extending to override just some methods) RIM's classes to use the library with the features you need.
But maybe some good news: About scanning images using video feed, I'm almost sure it's possible for OS 6, I think It's possible for OS 4.6 or 5.0 as well. It's usefull for auto detecting the code without the need to take a photo. I don't think that special or internal RIM api is needed to do this.
I'll try to find some sample code in the forum and post the link here, I have the idea I've seen some sample code like that, before.
03-25-2011 03:02 PM
Hi again, about scanning directly from video feed (continuously, without taking a photo) try this: http://supportforums.blackberry.com/t5/Java-Develo
I hope this helps!
03-26-2011 09:13 PM
Has anyone managed to get the barcodeapisample code working under OS 5? I can importthe zxing and rim files, however, still can't get the samepl working under OS 5. Is there a working OS 5 barcode sample using zxing available somewhere?
03-27-2011 12:20 AM