Detect 1D barcode area

297 views
Skip to first unread message

Luca Celenza

unread,
Oct 27, 2015, 7:46:15 AM10/27/15
to zxing
I have multiple barcodes on a TIFF file, all of them Code39Extended. The thing is I'd like to get the ResultPoint[] for the coordinates of the barcode's bounding box, instead of an inner horizontal line. Is it possible?

Bas Vijfwinkel

unread,
Oct 28, 2015, 2:37:51 AM10/28/15
to zxing
On Tuesday, October 27, 2015 at 8:46:15 PM UTC+9, Luca Celenza wrote:
> I have multiple barcodes on a TIFF file, all of them Code39Extended. The thing is I'd like to get the ResultPoint[] for the coordinates of the barcode's bounding box, instead of an inner horizontal line. Is it possible?

Currently that is not how the scanning algorithm is implemented so this won't be possible.

All the foundations for making that feature are available but you have to write that yourself.
A simple algorithm would be :
1. scan for a barcode
2. get start and end point
3. take some offset upwards/downwards and scan again
4. if you find the same barcode -> goto 3
5. if you find something no other barcode, you have found the upper/lower bounds of the barcode
6. strip the area from you input data and goto 1.
It is a very crude algorithm but might work without having to do much programming.

Of course a pattern detection algorithm would be far more effective.
But if you are really adventurous, you could also maybe have a look at OpenCV in order to detect barcodes.
It is basically a simple version of facial detection and OpenCV is pretty good/fast at that.

Luca Celenza

unread,
Oct 30, 2015, 5:12:24 AM10/30/15
to zxing
It's really a shame there's no actual out-of-the-box solution for this. Actually I do find curious the fact no one ever had to get the information and at least come up with an implementation, so chances are I'm the only one who needs this bounding box! Guess I'll try with OpenCV.

Sean Owen

unread,
Nov 1, 2015, 7:39:55 AM11/1/15
to zxing
Bas actually this is exactly what the MultipleBarcodeReader does for you. It can wrap a reader and search for several codes in this way.

Bas Vijfwinkel

unread,
Nov 1, 2015, 10:42:01 PM11/1/15
to zxing
Thanks for pointing out the MultipleBarCodeReader.
Correct me if I'm wrong but doesn't this search for multiple types on 1 page (and return the first barcode that is found for each type)?

I think what the poster asks for is to read all barcodes of 1 type in a single image.
But the implementation of MultipleBarcodeReader is definitely a good point to start for developing such a feature.

Bas Vijfwinkel

unread,
Nov 1, 2015, 10:52:05 PM11/1/15
to zxing
The number of people who need to scan 2 barcodes simultaneously is very limited because most products have only 1 barcode.
I have only seen books and payment forms with 2 barcodes so far.
And in those cases the store employees just scan each barcode individual with a handheld barcode scanner. I guess those POS systems were never designed for multiple barcode either.
Also laser scanners are not designed for multiple barcodes...

At least the ZXing code base offers all features you need for making such applications.
Use OpenCV if you have enough computing performance available and detection rate is more important than speed.
On a mobile device, I would suggest to make your own detection/scanning algorithm because ZXing is very fast.
Most OpenCV stuff on mobile phones have stripped most of the core libraries in order to have a decent performance.

Sean Owen

unread,
Nov 2, 2015, 3:45:28 PM11/2/15
to zxing
It wraps a Reader, so you can have it search for many of whatever a particular Reader supports, including just 1 barcode type.
Reply all
Reply to author
Forward
0 new messages