need scanning ITF length 4

161 views
Skip to first unread message

Jan Wassenaar

unread,
Oct 9, 2015, 4:06:46 AM10/9/15
to zxing
hi,

I need to scan ITF with length 4, but barcode scanner+ wants a minimum length of 6. And I don't see an entry in the settings to change the boundary lenghts for ITF.

When you try to scan ITF length 4, you can see that the barcode is read, but the result is not passed.

Is there a way to scan ITF with length 4?

I am new on android programming, but maybe someone can give me a hint and/or links to information pages so that I can try to do this by myself in an android app.

regards, jan wassenaar

Jan Wassenaar

unread,
Oct 9, 2015, 4:32:30 AM10/9/15
to zxing
I see now that on july 12 the same question has been posted:
https://groups.google.com/forum/#!topic/zxing/gFf7apiE6JI

The answer: use the DecodeHintType.ALLOWED_LENGTHS hint to change the default in https://github.com/zxing/zxing/blob/master/core/src/main/java/com/google/zxing/oned/ITFReader.java at line 54 private static final int[] DEFAULT_ALLOWED_LENGTHS = { 6, 8, 10, 12, 14 };

Has anyone already made a new app with this modification?

regards, jan wassenaar

Sean Owen

unread,
Oct 9, 2015, 9:55:02 AM10/9/15
to zxing
No; the problem is that it generates too many false positives. You can make your own build trivially, or call by Intent and pass a different setting.

Jan Wassenaar

unread,
Oct 9, 2015, 12:00:07 PM10/9/15
to zxing
It is a pity that such a good app as the zxing barcode scanner is, cannot be used by those who have chosen in the past to work with length 4 interleaved barcodes.
Besides I agree that in the current app, false positives cannot be prevented, for itf barcodes with length > 6.

A common practice in non-app scanning software is to add two boundaries for the itf length (under and upper), in the settings.

In this way each user can minimize the chance of false positives, regarding the lengths that are used in the specific situation.

Can we work together to add this in a next version of the zxing barcode scanner app? I think this will promote the use of the app.

Sean Owen

unread,
Oct 10, 2015, 7:52:50 AM10/10/15
to zxing
I think I said it can scan for whatever length you like, if you're integrating by Intent.
No, I'm not going to change the core app itself.

Lachezar Dobrev

unread,
Oct 12, 2015, 4:40:05 AM10/12/15
to Jan Wassenaar, zxing
  To give you a better advice on dealing with your issued please specify the way you're calling ZXing Barcode Scanner.

  There are two generally available methods to do that:
  - Scanning Via Intent (three variants)
  https://github.com/zxing/zxing/wiki/Scanning-Via-Intent

  All of these methods have a way (specific to the method) to instruct the ZXing Application to scan for Interleaved-Two-of-Five of specific lengths.

  If however you're expecting the general application to allow specific lengths out-of-the-box that would be unproductive, as ITF with small lengths is very susceptible to false-positives.

  I suspect, that you have a specific application where ITF with length 4 is expected. You can easily configure this Decode Hint there. In fact, I believe that to be a really reasonable thing to do, as you would be able to reduce the types of bar-codes that the application is looking for thus limiting the resources needed for the process.
  If this is so, take a look at the two pages I noted above, and feel free to ask for additional help.



--
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.

Jan Wassenaar

unread,
Oct 15, 2015, 4:47:00 PM10/15/15
to zxing, jan.wa...@artikelperfect.nl
Thanks for your offer for help.

The situation is that a webshop uses a few thousand crates for delivery.
Each crate has a label with a number of 4 digits and its ITF barcode.
I want to facilitate the returning of the crates, in such a way that a deliverer can scan the returned crates with his/her android smartphone, and send them to the webshop, to be processed in the backoffice.

So the process should then be as follows:
1) the deliverer scans, with an android smartphone with internet connection, one or more returned crates, using the zxing barcode scanner app
2) the deliverer goes in the barcode scanner app to the history and sends to a preconfigured ftp app, which places the scans as csv file on a web server.
3) on the webserver runs a schedule to read and process the csv files in the backoffice of the webshop.

But because the zxing barcode scanner does not scan the ITF of length 4, this does not work.

I read some information about Android Studio, and also the pages you suggested, but I cannot see yet what the best way is to solve this.

Can I simply load the zxing project in Android Studio, change the DecodeHintType.ALLOWED_LENGTHS to 4 only, and generate an app with a name such as Barcode Scanner ITF4?
Or is there a smarter way to do this?

Any help is appreciated.

Bas Vijfwinkel

unread,
Oct 16, 2015, 1:08:12 AM10/16/15
to zxing, jan.wa...@artikelperfect.nl

> Can I simply load the zxing project in Android Studio, change the DecodeHintType.ALLOWED_LENGTHS to 4 only, and generate an app with a name such as Barcode Scanner ITF4?
Basically, that is all that is needed for the standard app to recognise the ITF barcodes.
Because the allowed lengths setting is hardcoded, you need to rebuild the app so there is unfortunately no other way.
For the record, you need to set it like this :
private static final int[] DEFAULT_ALLOWED_LENGTHS = { 4, 6, 8, 10, 12, 14 };

For your general project, the standard app can be used as a basis and the communication with the server needs to be added.
Apps can store data locally and sending such data to a server is very simple.
But if using the smartphone's data connection is no issue, why not set the data directly?

Usually data can be stored directly in a database on the server and a web application can then easily access it to show the results. No need for storing data in CSV files.
Do make sure to make backups of your webserver and it's database just in case something happens.

In case building apps yourself is hard, try to find maybe an developer on one of those rent-a-coder sites. For people with experience in building apps the modification of the existing app should be no problem at all.
A simple web application to show the data can be build in a few weeks by 1 person.
Not that not all good app developers are good at making web applications and visa versa.
So you might want to have 1 person make the actual app and 1 person the web application including an API for the app to connect to.

Looking at your name, I presume you are from Holland. (Forgive me if I'm wrong).
If that is the case, and you are not in a real rush to make it, you could also consider taking it as a project to a university because they often have to do some project at a company before graduating. I'm not sure it is free, but those kids are in general smart enough to actually build it.

Good luck!


Lachezar Dobrev

unread,
Oct 16, 2015, 3:46:54 AM10/16/15
to Jan Wassenaar, zxing
  Hm. You've hit one of the two use cases where the generic ZXing Bar-Code Scanner does not fit well:
  1. Mass/Bulk scanning for third parties
  2. Interactive scanning with on-the-fly processing

  The send-history-as is a common way to work around the bulk/mass shortcomings.

  This however combined with the specific Bar-Code format and length that does provide a challenge.

  I tried a few thing. And found that crafting a broken URL may provide you with the functionality you need!
  Open the following URL in a browser on the Android device (you may make a book-mark):

    zxing://scan/?SCAN_FORMATS=ITF&ALLOWED_LENGTHS=4

   or (if you want to make a book-mark)
  This should open the ZXing Bar-Code Scanner, and configure it to read only ITF with length 4.
  This is probably a side-effect (the URL is missing a required parameter), but may help you.

  On the other topic: the change to allow 4-character ITF bar-codes would be trivial, but building the application will require some skill.

Jan Wassenaar

unread,
Oct 16, 2015, 4:56:42 AM10/16/15
to zxing, jan.wa...@artikelperfect.nl
Bas, thanks for your advices!
I'll let you know when I have any results.

Jan Wassenaar

unread,
Oct 16, 2015, 5:08:29 AM10/16/15
to zxing, jan.wa...@artikelperfect.nl
Lachezar, that is an interesting direction, I tried a few things:

- zxing://scan/?SCAN_FORMATS=ITF&ALLOWED_LENGTHS=4 does not give a result in the browser

- http://zxing.appspot.com/scan?SCAN_FORMATS=ITF&ALLOWED_LENGTHS=4 in the browser on the android device asks me to install the Barcode Scanner app in the Play Store. Because the app has been installed already I choose the OPEN button in Google Play Store. Scanning of ITF length 4 does not work yet.

Do I something wrong, and does ITF length 4 scan on your device with this url?

Lachezar Dobrev

unread,
Oct 16, 2015, 7:08:22 AM10/16/15
to Jan Wassenaar, zxing
  You're using the default Browser, not Chrome, not Firefox, not anything else, right?
  What model are you using?

  I'm on HTC One X, Android 4.2.2, and using either URL works fine, and with both I can successfully scan the attached bar-code.

itf.png

Jan Wassenaar

unread,
Oct 16, 2015, 7:45:56 AM10/16/15
to zxing
I'm using Chrome on Samsung Galaxy S3 mini, with Android 4.1.2.

Should I try with another browser?

When I go to url http://zxing.appspot.com/scan?SCAN_FORMATS=ITF&ALLOWED_LENGTHS=4 in the browser, the Barcode Scanner app then has to open, without asking for Google Play Store install?


Lachezar Dobrev

unread,
Oct 16, 2015, 10:27:13 AM10/16/15
to Jan Wassenaar, zxing
  Open it with the default browser.
  It should open the ZXing Barcode Scanner application, or at least ask you if you want to open the scanner.
  On my phone I added a Bookmark to that address (in the default browser), and then with a long-tap chose to add a short-cut to it on the home screen. Afterwards I could just tap the short-cut from the Home screen and it would open the ZXing Barcode Scanner configured.

  There seems to be a way to launch intents from Chrome with some crafted URL, but I can see no way to specify parameters/arguments that way.

Jan Wassenaar

unread,
Oct 17, 2015, 6:10:26 PM10/17/15
to zxing, jan.wa...@artikelperfect.nl
It works!
It's the "zxing appspot" link to the default browser that does it.
In first instance there was no change, but after reinstalling the barcode app,
booting, and reinstalling, the app scans (via the link) also the ITF length 4.

The "zxing scan" link to the default browser gives an error about webpage not available.
As default the browser makes the url in the http://zxing%3A%2F%2Fscan etc form,
i.e. with hex for the special symbols.
When I try to replace the hex codes by the special symbols, the browser rejects to save the favorite.
What form has your url?

Now that I scan the ITF length 4, I can program the webschedule to import the .csv file in the database of the webserver (what should be no problem for me).
Many thanks for your help!

Just one question: is there a chance that this functionality will end some time?

Op vrijdag 16 oktober 2015 16:27:13 UTC+2 schreef Lachezar Dobrev:

Lachezar Dobrev

unread,
Oct 19, 2015, 5:34:55 AM10/19/15
to Jan Wassenaar, zxing
  The *zxing://* URL is not designed to be written in the browser location bar, but rather to be used as a link on a web page, that is being viewed in the browser. The two URL I've given were already encoded properly, further encoding would make them dysfunctional. Technically both links should do the same, but it might be impossible to bookmark the *zxing://* one. The choice to which one to use is really up to you and your use case realisation.

  It eludes me why would you need to reinstall the ZXing Bar-Code Scanner. Are you sure you've had the official release, and not some third party modified variant? It might be that the browser somehow indexes which URL can be opened with a native application, but that seems far-fetched to me.

  Any way. To the best of my understanding you have an web page/application that the users interact with in a browser. You could add a link/button with either URL and something like 'Click Here To Scan Your Packages'. That /should/ hit the integration and ask the user to open the ZXing Bar-Code Scanner (with the settings applied).

  On the topic of function persistence I'm not an authority. This method side-steps a bit and it might be classified as a bug (although it seems benign) and then 'fixed'. The integration with the browser however has been one of the *key* functions of the ZXing Bar-Code Scanner, and it is improbable that it will go away.


Jan Wassenaar

unread,
Oct 20, 2015, 5:33:28 PM10/20/15
to zxing, jan.wa...@artikelperfect.nl
About the reinstall: in search of a ITF-4 capable app I had installed - besides the official zxing barcode scanner - several other scan apps (possibly modified variants of the zxing app). I uninstalled them while reinstalling the zxing barcode scanner app.
I understand that one of these other apps could be the reason for the zxing appspot link not to work.
This is good to know.


Op maandag 19 oktober 2015 11:34:55 UTC+2 schreef Lachezar Dobrev:
Reply all
Reply to author
Forward
0 new messages