How to use com.google.zxing.client.j2se.CommandLineRunner with only _part_ of an image?

1,067 views
Skip to first unread message

User

unread,
Mar 30, 2010, 7:47:13 PM3/30/10
to zxing
Hi,

I was wondering how I could use the CommandLineRunner (java -cp javase
\javase.jar;core\core.jar
com.google.zxing.client.j2se.CommandLineRunner [File]) to only process
part of an image. What I have are many large resolution images with
barcodes and the coordinates of the barcode on each image.
For example, in this image (img35.imageshack[.]us/img35/5220/
barsample.png ), the barcode is inside the rectangular region with a
top left corner of coordinates (206,41) and bottom right coordinates
of (1337, 165). Of course, the real images I use are much larger and
the barcode is in a relatively smaller region.

For efficiency, can ZXing (through commandline) to directly look only
at the rectangular region holding the barcode from this image itself.
I could write this region to a temporary file and pass this to ZXing
manually, but this will be very inefficient.

Anybody have any ideas of a command I could use to do this?

Thank you in advance!

Sean Owen

unread,
Mar 31, 2010, 2:30:06 AM3/31/10
to zxing
Yes, you'll need a very little bit of hacking though. Inside
CommandLineRunner, find where it creates a
BufferedImageLuminanceSource. This constructor can take four more int
parameters, the left/top coordinate and width/height of a rectangular
subregion to examine.

User

unread,
Mar 31, 2010, 1:33:43 PM3/31/10
to zxing
Thanks for the quick response, but I do not know Java. :'-( Also, I
would need to do this every time I upgrade ZXing.

If possible, can I request this feature be added to ZXing's command
line runner as it will be useful for other users as well?

Sean Owen

unread,
Mar 31, 2010, 2:23:27 PM3/31/10
to zxing
Easy enough, I just added this arg:

--crop=left,top,width,height

For your original example:

--crop=206,41,1131,124

User

unread,
Mar 31, 2010, 9:53:43 PM3/31/10
to zxing
I rebuilt the java classes with ant and it works!
Thank you so much for your help.

Best regards.

Stilgar Dragonclaw

unread,
Mar 30, 2017, 7:43:04 PM3/30/17
to zxing
Hi, I have android in Cyanogenmod version and I try launch BarcodeScanner (com.google.zxing.client.android) in Terminal Emulator (jackpal.androidterm)

I am using these sequence code:

$ java -cp javase
\javase.jar;core\core.jar
com.google.zxing.client.j2se.CommandLineRunne--crop=206,41,1131,124

or:

$ java -cp javase
\javase.jar;core\core.jar
com.google.zxing.client.android.CommandLineRunne--crop=206,41,1131,124

and these code:

$ adb shell am start -n com.google.zxing.client.android.CommandLineRunne

Does anyone know how to run a BS ZXing in Android terminal?

Thx for advice and tips.

Lachezar Dobrev

unread,
Mar 31, 2017, 7:59:51 AM3/31/17
to Stilgar Dragonclaw, zxing
The command-line runner is targeted towards a Java VM, not Android.
The Android application is an interactive application. They're based
on the same ZXing core functionality, but realise different
functionality and are not interchangeable.

That said, I am not familiar with Cyanogen Mod, but I do not believe
it has a Java (SE) VM, so no command-line runner there.
> --
> You received this message because you are subscribed to the Google Groups "zxing" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to zxing+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Stilgar Dragonclaw

unread,
Mar 31, 2017, 6:08:48 PM3/31/17
to zxing, stilgar.d...@gmail.com
Yep, here is correct tree / package path: https://github.com/zxing/zxing/tree/master/android/src/com/google/zxing/client/android

It will be suffice, when someone shows me the script to run zxing barcodescanner in android terminal.
Just what is called when you click on the application icon.

Does anyone know?

THX

Reply all
Reply to author
Forward
0 new messages