ZXing scanning speed

3,502 views
Skip to first unread message

chiew jun hao

unread,
Oct 9, 2011, 5:33:16 AM10/9/11
to zx...@googlegroups.com
Hi ZXing team,

I am currently developing this Android phone Application which uses the installed ZXing in the phone to scan barcode. However, when I press the in my app to activate the scan function, the scanning speed is not as fast as when I run the original ZXing app. Do you happen to know why?

Sincerely,
Jun Hao

Sean Owen

unread,
Oct 9, 2011, 6:55:49 AM10/9/11
to zx...@googlegroups.com
Since nobody but you knows your code and what you've modified, no, it's really not possible to say.
Maybe you didn't enable Proguard.

chiew jun hao

unread,
Oct 11, 2011, 5:37:57 AM10/11/11
to zx...@googlegroups.com
I used the codes you provided in the ZXing website http://code.google.com/p/zxing/wiki/ScanningViaIntent
May I know what is proguard?

Sean Owen

unread,
Oct 11, 2011, 6:19:58 AM10/11/11
to zx...@googlegroups.com
If you're integrating by Intent, then you are launching the exact same app, so it should not be different.
Maybe you are requesting to scan for all formats, by Intent, which is slower, while configuring the app to scan for only one format? That could explain the difference.
Proguard is a byte-code optimizer.

chiew jun hao

unread,
Oct 12, 2011, 8:10:05 AM10/12/11
to zx...@googlegroups.com
I set the format to UPC 13. Is there any extras that I need to set?

Sean Owen

unread,
Oct 12, 2011, 8:27:08 AM10/12/11
to zx...@googlegroups.com
You mean UPC_A, or EAN_13, I hope. There's no UPC 13 format. If it's invalid like this, you will default to scanning for all the default formats, which could be why it's slower.

chiew jun hao

unread,
Oct 16, 2011, 8:18:17 PM10/16/11
to zx...@googlegroups.com
Sorry, I mean UPC_E_MODE for SCAN_MODE

Sean Owen

unread,
Oct 17, 2011, 3:05:58 AM10/17/11
to zx...@googlegroups.com
That's also incorrect -- you need "UPC_E", not "UPC_E_MODE". This would also cause the behavior I mention.

chiew jun hao

unread,
Oct 17, 2011, 4:29:30 AM10/17/11
to zx...@googlegroups.com
Oh, but both UPC_E_MODE and UPC_E works

Sean Owen

unread,
Oct 17, 2011, 10:18:30 AM10/17/11
to zx...@googlegroups.com
No, it doesn't work. If you send "UPC_E_MODE" it will ignore your setting and scan for all formats.

chiew jun hao

unread,
Oct 17, 2011, 11:05:22 PM10/17/11
to zx...@googlegroups.com
Alright! Thank you! Just one more question. I know that the zxing can scan the barcode horizontally. Can it detect and scan the barcode both vertically and horizontally at the same time?

Sean Owen

unread,
Oct 18, 2011, 3:03:34 AM10/18/11
to zx...@googlegroups.com
You would have to rotate the image 90 degrees to scan the other way. In one pass it will only scan forwards and backwarrds.

chiew jun hao

unread,
Oct 18, 2011, 9:19:17 AM10/18/11
to zx...@googlegroups.com
What do you mean by scan forwards and backwards?

I am trying to make it detect horizontal barcode and vertical barcode at the same time. So if the barcode happen to be vertical instead of the usual horizontal way, the ZXing can also scan.

Sean Owen

unread,
Oct 18, 2011, 11:02:31 AM10/18/11
to zx...@googlegroups.com
I mean scan at about 0 or 180 degree rotation.
Like I said -- you have to write code to rotate the image, then scan, if you want 90 / 270. It's not hard.

chiew jun hao

unread,
Oct 18, 2011, 9:24:00 PM10/18/11
to zx...@googlegroups.com
Wow, that sounds tough. Do I have to download the library from the ZXing and then develop from there? If yes, is there any links you can recommend? I am just an average programmer currently, do you think I can accomplish this?

Sincerely,
Jun Hao

Sean Owen

unread,
Oct 19, 2011, 3:17:00 AM10/19/11
to zx...@googlegroups.com
Yes. It's just a few lines of code. There are already methods to rotate the LuminanceSource image 90 degrees. You would just also scan the rotated object.

chiew jun hao

unread,
Oct 25, 2011, 1:07:14 AM10/25/11
to zx...@googlegroups.com
My intentIntegrator does not display the downloadDialog if the barcode scanner is not installed. I have tried searching stackoverflow, but to no avail. Do you happen to know why?

Thanks in advance!:D

Sean Owen

unread,
Oct 25, 2011, 4:50:18 AM10/25/11
to zx...@googlegroups.com
No, because it does show the dialog. If you've changed the code, you need to debug it yourself. Break on "ActivityNotFoundException" and see what's happening.

chiew jun hao

unread,
Oct 30, 2011, 10:12:29 PM10/30/11
to zx...@googlegroups.com
No, I did not change any codes inside the intentIntegrator. I followed the short codes according to this website http://animate-innovations.com/content/integrating-qr-codes-android-app-zxing

What do you mean by 'Break on "ActivityNotFoundException"'? I have never done that before

Thanks in advance!:D

David Williams

unread,
Oct 30, 2011, 10:31:01 PM10/30/11
to chiew jun hao, zx...@googlegroups.com

use zxing android interface
set scan types in options menu
set try harder off
dont use multipart reader if you dont need to

On 2011 10 11 05:38, "chiew jun hao" <terrorbl...@hotmail.com> wrote:

I used the codes you provided in the ZXing website http://code.google.com/p/zxing/wiki/ScanningViaIntent

May I know what is proguard?



On Sun, Oct 9, 2011 at 6:55 PM, Sean Owen <sro...@gmail.com> wrote:
>

> Since nobody but you knows...

chiew jun hao

unread,
Oct 30, 2011, 10:51:52 PM10/30/11
to zx...@googlegroups.com
ok I solve it!

chiew jun hao

unread,
Nov 7, 2011, 7:34:44 PM11/7/11
to zx...@googlegroups.com
I am trying to integrate ZXing library project into my application and google searched a lot of blogs and forums on how can I do so, but to no avail. Is there any link that you can recommend?

chiew jun hao

unread,
Nov 15, 2011, 9:03:38 AM11/15/11
to zx...@googlegroups.com
I found this link below and tried to put it inside my Android library project, but there are no awt.bufferedimage for me to use. My jdk is 1.6 which is up to date. Am I suppose to download some software for this or did I followed the wrong link? Thanks in advance!:D

Lachezar Dobrev

unread,
Nov 15, 2011, 11:49:20 AM11/15/11
to chiew jun hao, zx...@googlegroups.com
Android is _NOT_ Java.
You can only use a subset++ of the Java SE classes in Android.

http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/PlanarYUVLuminanceSource.java

I believe it's accepted to copy this class (Sean? Daniel?).

However be warned, that this implementation does NOT support
rotation. You'll have to do it yourself.

2011/11/15 chiew jun hao <terrorbl...@hotmail.com>:

Sean Owen

unread,
Nov 15, 2011, 12:43:35 PM11/15/11
to zx...@googlegroups.com, chiew jun hao
Sure, it's open source. You can copy and use it if you follow the license terms.
Yes, you can't use all JavaSE code on Android. That's why that class is in javase/, not android/!

chiew jun hao

unread,
Nov 20, 2011, 9:47:52 PM11/20/11
to zx...@googlegroups.com
So that means I can't use this link for rotation of the image for scanning? http://code.google.com/p/zxing/source/browse/trunk/javase/src/com/google/zxing/client/j2se/BufferedImageLuminanceSource.java?r=1697

I am trying to modify the library project such that it can scan barcode both vertically and horizontally, then further develop it to be able to scan at any angle. Do you think it is possible to do so?

chiew jun hao

unread,
Nov 21, 2011, 3:58:23 AM11/21/11
to zx...@googlegroups.com
In YUVLuminanace, does the reverseImage mean that it rotate the image by 180 degrees for scanning, or invert the image laterally?

On Wed, Nov 16, 2011 at 1:43 AM, Sean Owen <sro...@gmail.com> wrote:

Lachezar Dobrev

unread,
Nov 21, 2011, 4:00:00 AM11/21/11
to chiew jun hao, zx...@googlegroups.com
Yes, you can not use this in Android. You will have to extend the
PlanarYUVLuminanceSource, so that it supports rotation.

2011/11/21 chiew jun hao <terrorbl...@hotmail.com>:

Lachezar Dobrev

unread,
Nov 21, 2011, 4:01:48 AM11/21/11
to chiew jun hao, zx...@googlegroups.com
Reverse Image is used to create a horizontal mirror image to handle
input from forward-facing cameras. This is NOT equivalent to rotation.

2011/11/21 chiew jun hao <terrorbl...@hotmail.com>:

Sean Owen

unread,
Nov 21, 2011, 4:14:48 AM11/21/11
to zx...@googlegroups.com
Rotating the image is part of the task, but is the easy part, really. You need to account for camera rotation and orientation in order to know how much to rotate it, too.

Lachezar Dobrev

unread,
Nov 22, 2011, 3:58:16 AM11/22/11
to chiew jun hao, zxing
It means you have to copy the source to your project, and add
rotation support.

2011/11/22 chiew jun hao <terrorbl...@hotmail.com>:
> Ok, so does that mean that I have to remove the final modifier in the
> PlanarYUVLuminanace?

Lachezar Dobrev

unread,
Nov 22, 2011, 4:02:11 AM11/22/11
to chiew jun hao, zxing
And by copy I mean the PlanarYUVLuminanceSource class _only_, not
the whole android project.

2011/11/22 Lachezar Dobrev <l.do...@gmail.com>:

chiew jun hao

unread,
Nov 27, 2011, 7:59:36 PM11/27/11
to zx...@googlegroups.com
Why do we need to account for camera rotation and orientation? I found this link that rotate images using matrix.postscale, will it work if I want to rotate the image for scanning?

Sean Owen

unread,
Nov 28, 2011, 5:22:53 AM11/28/11
to zx...@googlegroups.com
Sure, but how do you know how much to rotate the image if you don't know the camera's rotation and orientation?

chiew jun hao

unread,
Nov 28, 2011, 6:49:56 AM11/28/11
to zx...@googlegroups.com
I am trying to make it such that, if the decoding is unsuccessful or 'catch (ReaderException re)' in DecodeHandler, it will use matrix.postRotate(90);to rotate the image by 90 degrees and decode again, is that possible?

Sean Owen

unread,
Nov 28, 2011, 9:49:54 AM11/28/11
to zx...@googlegroups.com
Sure, you can do whatever you like. This seems really inefficient though -- you're going to complete 0-3 scans that won't succeed.
Reply all
Reply to author
Forward
0 new messages