01-03-2011 07:41 AM
02-23-2011 05:56 PM - edited 02-23-2011 05:59 PM
You guys have to integrate ZXing core and the RIM specific bits into your app (better off just importing the ZXing library classes into your project).
Also, disregard the J2ME Image-specific LuminanceSource class, since it isn't as effective as using a native Bitmap subclass, which you have to implement on your own. In other words, J2ME Image's setRGB() in LCDUIImageLuminanceSource is almost identical to Bitmap's setARGB(), so it should be trivial to create a LuminanceSource subclass to support Bitmap instead of Image. Then, just find a way to create a Bitmap object from the captured image file (open file, get the file's inputstream to create EncodedImage, and then get that object's Bitmap). As a result of using Bitmap, I was able to scan 1D (w. auto-focus camera of course), and processing times decreased.
Also, make sure that the FileSystemJournalListener is removed only when you have an image file path (i.e. ends with ".jpg"), since there are cases where it sends back other non-image paths, or it sends image paths where it doesn't start with "IMG", since I recently saw this on the BB Torch when geotagging is enabled when capturing an image.
Finally, do not use the threading routines in the test app verbatim, since they are running on the Event Thread and that's a big no-no for a heavy task such as this one. Instead, spin them off as a separate Thread, and just get the event lock to close screens and so forth within it. Also, this task can hang if processing a large image, so you should find a way to check if it timed out (second watchdog thread to check if it's still processing).
02-24-2011 08:13 AM
Diego, thanks for all your advices. It would be awesome if you could share your BitmapLuminaceSource with us.
I'm developing an application with 1D barcode reader that should support OS versions less than 5.0. I got it working but it's very hard to take a decent picture with these devices, actually I was able to decode only large barcode images from the internet.
Somebody told me that would be better to do a continuous scan rather than taking only one photo of the barcode, but I don't know how to do that, I'm new in using ZXing. Do you know anything about this approach?
02-24-2011 08:21 AM - edited 02-24-2011 08:23 AM
I got mine working doing what this guy said:
Besides the whole library and core stuff, you will have to get the com.google.zxing.client.rim package and also the com.google.zxing.client.j2me to get the LCDUIImageLuminescence file. Then just check how it's done in the ZXingLMMainScreen.
And follow what diegotri said.
02-24-2011 10:20 AM - edited 02-24-2011 10:25 AM
That Bitmap-specific LuminanceSource file is currently proprietary to our app, so I can't share the source code. However, here's a hint: take a look at LCDUIImageLuminanceSource's setRGB functions. All I did was convert the J2ME Image object into Bitmap and modify it to its respective functions and that was it. Piece of cake it was. Also, if running this app on OS 6.0, make sure to give it different class name other than BitmapLuminanceSource, since it'll conflict with RIM's version.
Finally, for 1D, as long as you get a clean and sharp shot of the barcode from an auto-focus camera, it'll scan perfectly. Remember for ZXing, you have to define the type of barcodes you want the API to decode, so narrow the scope as to what you want to scan.
02-24-2011 11:04 AM - edited 02-24-2011 12:33 PM
But what about the continuous scanning using the video camera? Someone has told me that it works in the iPhone. I don't know, since it mainly would be getting many pictures to try to decode while the user points to the barcode, I think decoding the image take too much time to get an advantage from this approach. And it would not help anyway if the device camera doesn't have auto-focus.
Do you think it's worth a try?
02-24-2011 01:08 PM
Continuous scan is next to impossible to pull off on anything below 6.0, since RIM doesn't allow devs access to the raw video frames. That and trying to capture it in a thread that takes images every second would just be too intensive for the platform. Even then, I was able to capture 1D on a single shot using the external camera a FileSystemJournalListener and it worked fine.
02-28-2011 10:32 AM
Guys, I couldn't make this work. Even using devices which has the auto-focus feature, and taking good pics of the barcode.
This is how I'm proceeding:
1- Add a FileSystemJournalListener and invoke camera
2- When the fileJournalChanged is called (picture taken) I get the entry path and confirms that it is an image.
3- I run a new Thread to get the image, and then I create the BinaryBitmap, using a HybridBinarizer with the LCDUIImageLuminanceSource I got from the image file.
4- I try to decode using a MultiFormatReader with the hints: PURE_BARCODE and TRY_HARDER.
That's it, I get that from the ZXing Blackberry example, I didn't change much of it, but it didn't work as expected. I was only able to decode large barcode images that I got in the internet. Is there anything else that I can do to improve the detection?
I would very much appreciate any help.
I'm sending the BarcodeReader file I created to do all that stuff.