Issue 183 in zxing: Enhancement: find multiple barcode into an image

692 views
Skip to first unread message

codesite...@google.com

unread,
Apr 28, 2009, 10:48:36 AM4/28/09
to zx...@googlegroups.com

Comment #6 on issue 183 by gentuser: Enhancement: find multiple barcode
into an image
http://code.google.com/p/zxing/issues/detail?id=183

Hi
I'm trying to do what you suggest: scan and find the first barcode. Look at
the
coordinates of the result points in the returned value.
I'm just trying to see if I can recognize multiple barcodes into a tiff
image recived
from a fax. This is a very experimental application.
The problem is that I don't know where is these barcodes (their
coordinates), so the
first suggestion is more suitable for my case. Thanks again.


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

codesite...@google.com

unread,
Apr 28, 2009, 10:54:41 AM4/28/09
to zx...@googlegroups.com

Comment #7 on issue 183 by gentuser: Enhancement: find multiple barcode

Hi
I'm trying to do what you suggest: scan and find the first barcode. Look at
the
coordinates of the result points in the returned value.
I'm just trying to see if I can recognize multiple barcodes into a tiff
image recived
from a fax. This is a very experimental application.

The problem is that I don't know where are these barcodes (their

codesite...@google.com

unread,
Apr 28, 2009, 1:38:51 PM4/28/09
to zx...@googlegroups.com
Updates:
Status: Fixed

Comment #8 on issue 183 by srowen: Enhancement: find multiple barcode into
an image
http://code.google.com/p/zxing/issues/detail?id=183

OK I just checked in my changes. Try out
com.google.zxing.MultipleBarcodeReader!
Going to mark it fixed, tentatively, but reopen for further discussion.

codesite...@google.com

unread,
Apr 28, 2009, 6:04:14 PM4/28/09
to zx...@googlegroups.com

Comment #9 on issue 183 by hannibal218bc: Enhancement: find multiple
I've taken a look at the code, and if I understood it right it will fail to
find and
decode codes that do not fully fit into one of the areas
above/left/right/below the
previously found code, e.g. one larger code that is rotated 90° and is
placed besides
the first code, but starts above and ends below the first code. (Is it
clear what I
mean? If not, I'll post a drawing)

For QR Codes, as I pointed out at
http://code.google.com/p/zxing/issues/detail?id=45#c12 , this solution
needs many
resources to find the same patterns over and over. Futhermore, with my test
images,
the selectBestPatterns() method in FinderPatternFinder always chooses
inappropriate
tuples of finder patterns and does not read one single QR code (although it
recognizes almost all finder patterns in the image).

Perhaps we should introduce a new
public interface MultipleReader extends Reader

that will be implemented by readers that support decoding multiple codes at
once? The
MultiFormatReader() could then ask those readers that support it to return
all codes
or, as currently checked in, jigsaw the image and run multiple processing
iterations
on the remaining areas of the image.

codesite...@google.com

unread,
Apr 28, 2009, 6:13:18 PM4/28/09
to zx...@googlegroups.com

Comment #10 on issue 183 by srowen: Enhancement: find multiple barcode into
an image
http://code.google.com/p/zxing/issues/detail?id=183

If I understand your example correctly and wrote the code correctly, nah it
will take
care of that situation. It scan the entire area left of the first code,
from top to
bottom.

A sort of skewed code wouldn't be detected. I am aiming at what I perceive
to be the
common case, where barcodes aren't too close to one another anyway.

Yep, still doesn't really work for QR codes for the reason you cite. I
don't know of
a decent way around that. If there were an alternate approach that could
accommodate
this sort of thing, sure, then we'd want an interface + implementations for
MultipleBarcodeReader.

I think the solution for QR codes and perhaps other 2D formats would be
something
like... subdivide the image into quarters and smaller quarters until you
find a
barcode. Then proceed as in the current code I checked in. That is, try to
look at
small sections of the image to hit on a section that contains only one
barcode and
succeed. Once you toss in a twist to catch the case where the barcode is in
the
middle, I think it'd work. I'll play with it.

codesite...@google.com

unread,
Apr 28, 2009, 7:31:24 PM4/28/09
to zx...@googlegroups.com

Comment #11 on issue 183 by hannibal218bc: Enhancement: find multiple

Since I've played around with the QR Reader to support multiple codes, I'm
attaching
my changes as a patch against Rev#919 . I'd be glad if you can use some of
it.

Attachments:
zxing-issue-183_multiple_qr_codes_patch1.zip 9.8 KB

codesite...@google.com

unread,
Apr 30, 2009, 3:15:33 PM4/30/09
to zx...@googlegroups.com

Comment #12 on issue 183 by srowen: Enhancement: find multiple barcode into
an image
http://code.google.com/p/zxing/issues/detail?id=183

I went a different way with this. I moved MultipleBarcodeReader to the
com.google.zxing.multi subpackage, and added there a Reader wrapper called
ByQuadrantReader. This tries to find a barcode by looking in one quarter of
the image
at a time, which could in many cases avoid the issue that prevents any QR
code from
being found in an image with many QR codes. Putting the two together, I
hope, works
for this situation as well.

codesite...@google.com

unread,
Apr 30, 2009, 6:18:57 PM4/30/09
to zx...@googlegroups.com

Comment #13 on issue 183 by hannibal218bc: Enhancement: find multiple

Sounds great, but I still don't understand why you dislike the approach to
use the
already identified finder patterns (as seen in my patch)?
For non-QR-codes, the quadrant/roundabout approch is sure great.

codesite...@google.com

unread,
Apr 30, 2009, 6:32:03 PM4/30/09
to zx...@googlegroups.com

Comment #14 on issue 183 by srowen: Enhancement: find multiple barcode into
an image
http://code.google.com/p/zxing/issues/detail?id=183

My main concern is that it impacts the common case of searching for one
barcode -- I
would much rather put all the overhead burden on other code devoted to
scanning for
multiple barcodes. That is, I really would not like to touch the core
decoder for
this use case at all. It looks like a substantial change that also alters
the
settings that were (in theory) tuned for the common case of detecting 1
barcode.

I am reading off the diff, so am perhaps not correctly understanding the
patch, but
is it not basically looking for all finder patterns in the image first,
then trying
to figure which ones go together? it makes some sense. (It is specific to
QR codes
though). One of the assumptions that parts of the code relies on is that
finder
patterns are of the same size, and using that, can discount some 'false
positives'
along the way. If you discard that assumption because you're potentially
looking for
many codes, I think the detection may degrade. But I may not be getting the
patch, I
am just skimming it quickly here.

So I'm comparing that to a tidy and general solution that *should* work
pretty well.
Anything equally tidy that works better I'm sure willing to entertain.
Anything
that's less tidy could still be fine if it is worthwhile -- improves this
multi-barcode use case so much that it's worth altering the code for the
common case.
I guess I'd be surprised if that's easy to do but am sure open to it.

codesite...@google.com

unread,
Apr 30, 2009, 7:48:41 PM4/30/09
to zx...@googlegroups.com

Comment #15 on issue 183 by hannibal218bc: Enhancement: find multiple

There are currently two independent locations in the current SVN code that
use the
module sizes:

1. the detection in FinderPatternFinder to optimize detection speed (not
quality!)
2. the selection of the pattern locations that are passed to the decoder

The idea behind the patch for step (2) is, as you explained: take the finder
locations that were detected in (1) and not just return one tuple of three
finders,
but return many tuples of three finders. If there were just three finders
detected,
the patch does not imply any additional overhead but will just return that
one region.
The check for about-equal module sizes is in (2) so it will not affect the
detection
of finder patterns.

The current SVN code for (1) already detects as many finder patterns as it
can, but
there seem to be some optimizations that try to reduce scanning time. E.g.
the number
of skipped rows while scanning for black pixels is adjusted to the module
size of the
first finder pattern. I haven't thought about this until now... so yes, the
patch
will [perhaps only slightly] increase the amount of required processing for
detection. This would especially be true for codes with large pixel/module
ratios
where more rows could be skipped than in search for a possible small code.

There already is a TRY_HARDER hint that will disable at least some of these
tweaks
and assumptions so perhaps we can more or less not touch the current
detection
algorithm but just add some switches/ifs to disable all optimizations for
TRY_HARDER .


The selection of multiple code locations in the patch (for step (2) ) works
as follows:
- Sort the finders by their "expected module size" (= pixels per module,
not modules
in the code!)

- Check any tuple of three finders and discard any where
-- module sizes differ too much
-- the patterns cannot be three corners of a square (check angle and edges'
lengths)

The ordering by module size helps a lot to reduce the number of potential
results
when codes have different printout sizes or appear in different sizes on
the image.
If the module since of finders of one code differs too much, decoding will
fail
anyways so we can safely sort those regions out.

The rest of the patch disables the throwing of ReaderExceptions() that
would prevent
the processing of all of the code locations.


At first I was pretty sure that the patch wouldn't affect the 1-code case,
but I was
wrong: the finder detection is a bit worse, especially if there is only
one, big QR
code in the image [which will be the default for mobile detection...].
So perhaps the best solution would be to create two FinderPatternFinders,
one that is
optimized for fast detection of a single code, and one that is optimized
for thorough
detection of possibly more than 1 code. I guess something like that was the
rationale
for the TRY_HARDER hint, so why not use it for this?

I guess the logic for the later steps (location selection in (2) and
decoding) could
be kept together since the handling of multiple regions/results does not
impose a
large overhead, if any at all.

codesite...@google.com

unread,
May 2, 2009, 11:32:04 AM5/2/09
to zx...@googlegroups.com

Comment #16 on issue 183 by srowen: Enhancement: find multiple barcode into
an image
http://code.google.com/p/zxing/issues/detail?id=183

I like the idea here -- wanted to continue the discussion even though I
have not had
time to think through this fully.

I don't mind slicing up the current QR code decoder into enough pieces that
one could
write a separate multi-QR code reader, separately, that reuses as much as
it can.
That is, I can see modifying the core code to introduce more hooks, break
up into
more pieces, mostly. Most of the work would be in a separate implementation
that
specifically supports multiple codes.

Yes I generally agree with the approach you propose, that it should
a "TRY_HARDER"
mode function only, and that it probably involves creating some parallel
code that
works differently.

How to manage this parallel implementation? One approach to this is to do a
lot of
copy-and-paste and just reorient the code for the multiple-barcode case.
That may be
entirely fine for your use case. Should that go into the project? I'm
reluctant to
commit code that's mostly copy-and-paste, but not 100% against it if there
is a
demonstrable need.

Truly refactoring this all to accommodate both cleanly is probably hard, but
possible. If it works, doesn't affect the single-barcode case in any
substantive way,
is clean, and duplicates little code, I'm into it.

It's not at the top of my list, and the patch would have the be pretty
clean to be
worthwhile... just because I'm not sure how often you would want to find
multiple 2D
barcodes in an image? in such a way that the code I checked in wouldn't
work? I am
having trouble thinking of the use case.

codesite...@google.com

unread,
May 2, 2009, 7:21:46 PM5/2/09
to zx...@googlegroups.com

Comment #17 on issue 183 by hannibal218bc: Enhancement: find multiple

I planned to to "benchmark" the current SVN code to the proposed patch, but
I
couldn't. I've run into the following issues:
- the ByQuadrantReader does not return multiple Results, but just one. How
should
this class be invoked? I'm also not sure that it will cover really all
cases of QR
code layouts (e.g one large code in the center that stretches just out of
the center
region bounds).
- the MultipleBarcodeReader does not return any useable results. With
TRY_HARDER it
decodes not one single code; with*out* TRY_HARDER it detects 3. The patched
reader
successfully decodes 39 codes of the same images.

I thought about your comment, and I guess a good way to implement this in
source code
would be to subclass the QRCodeReader/FinderPatternFinder and override
those pieces
that need to be different for multi codes. That way, the patch would
propably shrink,
and only add some additional code instead of heavy modifications to
existing methods.
Reading your comment I suppose it is OK if I'll give that a shot and submit
a new
patch... ;-)
By the way, thank you for your support!

codesite...@google.com

unread,
May 3, 2009, 1:47:11 AM5/3/09
to zx...@googlegroups.com

Comment #18 on issue 183 by srowen: Enhancement: find multiple barcode into
an image
http://code.google.com/p/zxing/issues/detail?id=183

ByQuadrantReader is just intended to solve the problem that you might find
zero
barcode in an imagine with multiple barcodes, by searching parts of the
image. It
will return at most 1. It is intended to be used in conjunction with the
MultipleBarcodeReader.

No, none of these solutions can guarantee to find all barcodes in all
cases. In
particular I can think of odd cases where barcodes are at an angle and span
an area
sweeping from left to above another barcode, but, I imagine these are
pretty rare cases.

I am still curious what your use case is. Some people wanted multiple 1D
barcodes
since they used this for form processing, which might have 2-3 1D barcodes.

Yes feel free to take a shot at this. My main 'requirements' for the patch
would be
that it not meaningfully slow down the single-barcode case, and that it
doesn't
change the single-barcode decoder much except to slice it up for easier
reuse. I'm
much more open to adding code under com.google.zxing.multi.

In fact why don't I go ahead and implement your suggestion to make an
interface to
encapsulate a "MultipleBarcodeReader" type, since sounds like there may be
another
implementation.

codesite...@google.com

unread,
May 3, 2009, 2:35:04 PM5/3/09
to zx...@googlegroups.com

Comment #19 on issue 183 by hannibal218bc: Enhancement: find multiple

I've had some spare time this night and already have put together a less
invasive
version of the patch, which is attached.

There is some code in FinderPatternFinder duplicated, but I thought it
would be too
invasive to add more ifs/flags to the existing code. A few fields had to be
changed
from private to protected and I had to remove the "final" from the
FinderPatternFinder and Decoder classes. It even was possible to not use
TRY_HARDER
by default, so there are still two processing qualities available.

The use case here is: users print out a bunch of things (think of ads for
newspapers)
and arrange these paper snippets into groups (think of newspaper pages).
Then they
take a picture of this "collage" (one image per "page") and send it away to
where it
belongs. At the moment, the users need to manually compare a list of
objects-to-place
to the objects that are actually placed and confirm everything is OK.
What I'd like to do is print a QR code on every snippet and then process
the image to
automatically detect whats there. We're talking about 100-200 snippets in
approx.
10-20 groups, so the manual check really take precious time. Futhermore,
the QR code
allows me to calculate the relative positions of the snippets and their
orientation
(that's why I plan to use QR codes) which may be interesting in the future.

Attachments:
zxing-issue-183_multiple_qr_codes_patch2.zip 6.6 KB

codesite...@google.com

unread,
May 3, 2009, 3:58:22 PM5/3/09
to zx...@googlegroups.com

Comment #20 on issue 183 by srowen: Enhancement: find multiple barcode into
an image
http://code.google.com/p/zxing/issues/detail?id=183

I'd like to put the new code under com.google.zxing.multi(.qrcode) to avoid
adding to
the core code. There's also already an interface called
MultipleBarcodeReader there.
The other changes look about right, to allow for extension.

Any chance you can change it along those lines, or else, just post the
source files
here -- will be easier for me to add them that way and then make the tweaks
to the
existing code rather than even bother applying a patch and backing part of
it out.

codesite...@google.com

unread,
May 3, 2009, 4:27:28 PM5/3/09
to zx...@googlegroups.com

Comment #21 on issue 183 by hannibal218bc: Enhancement: find multiple

I'm note sure I understand what you mean. I'll move the new classes to
com.google.zxing.multi.qrcode , but that won't exclude them from the core
code, will it?
Or did you mean to move to code out of core/ to javase/ ?

Regarding the files, you mean I shall attach a zipped (svn export?) copy?
Thank you
for clarification!

codesite...@google.com

unread,
May 3, 2009, 4:31:28 PM5/3/09
to zx...@googlegroups.com

Comment #22 on issue 183 by srowen: Enhancement: find multiple barcode into
an image
http://code.google.com/p/zxing/issues/detail?id=183

Sorry I just mean keeping the changes mostly out of
com.google.zxing.qrcode; this all
stays in core/, indeed.

If you can just attach the entire source code for the new classes, that's
good. It'll
be easier for me than applying a patch, strangely, since I have some other
oustanding
changes. So I'd need to stitch it in anyway, and I want to have a quick
look at each
change anyhow, so editing in some changes by hand is reasonable.

codesite...@google.com

unread,
May 3, 2009, 4:35:29 PM5/3/09
to zx...@googlegroups.com

Comment #23 on issue 183 by hannibal218bc: Enhancement: find multiple

Bah, just realized there's a drawback: if we move the classes out into a
different
package, we will have to modify a lot of protected / default visible
classes and
methods to be public. Is this OK or better to keep stuff together? Since
the classes
are all named Multi... it's pretty clear what that is.

codesite...@google.com

unread,
May 3, 2009, 5:00:30 PM5/3/09
to zx...@googlegroups.com

Comment #24 on issue 183 by srowen: Enhancement: find multiple barcode into
an image
http://code.google.com/p/zxing/issues/detail?id=183

True, that might make putting it in a separate package annoying. I guess
I'd like to
start from that point (code in separate package), with your source files
and patch in
hand, and have a look myself. I don't mind if it doesn't quite compile
even, I can
handle looking at those details.

I don't mind doing the surgery to connect it all since I suppose I'd like
to tweak
how it all fits together, and take some decisions about how to incorporate
the
change. I hope that's OK -- of course the major part of the code you've
written will
stay as-is, just a question of how it's connected to the other code.

codesite...@google.com

unread,
May 3, 2009, 5:45:42 PM5/3/09
to zx...@googlegroups.com

Comment #25 on issue 183 by hannibal218bc: Enhancement: find multiple

OK, I don't mind whatever you will do with the code. Attached is a ZIP with
the
modifications; there are three new files (in com.google.zxing.multi.qrcode)
and a
modified Detector (in com.google.zxing.qrcode.detector), but it's just a
split-up of
one method.

There's one difference to the previous patches, I've decided to leave the
QRCodeReader untouched and create a new "QRCodeMultiReader extends
QRCodeReader
implements MultipleBarcodeReader" class and moved the decodeMultiple()
methods to it.
That way, the existing code remains untouched (except for the Decoder hook).

Since you've offered to do the wiring, I've removed all other minor changes
such as
removing the "final"/"private" modifiers.

Thanks again, Sean, for considering this change!

Attachments:
ZXing-Issue183-Patch.zip 13.2 KB

codesite...@google.com

unread,
May 5, 2009, 2:37:49 AM5/5/09
to zx...@googlegroups.com

Comment #26 on issue 183 by srowen: Enhancement: find multiple barcode into
an image
http://code.google.com/p/zxing/issues/detail?id=183

Here's the state of the patch now. I had to make some changes to make sure
it
compiles in Java 1.2 / J2ME. Overall, looking OK by me. There's two things
that still
give me some concern:

- This will impact the ability of ProGuard to optimize the QR Code reader
code since
many things are now overrideable, and can't be inlined, things like that. I
don't
think they are quite performance-critical, but not clear whether it makes,
say, a
0.01% difference or 1% or what

- The 'find' code is still a big copy and paste. Do you think there are
ways we could
refactor this more, if I committed this and we went from there?

Attachments:
Multi_QR_code_reader.patch 24.7 KB

codesite...@google.com

unread,
May 5, 2009, 4:28:21 AM5/5/09
to zx...@googlegroups.com

Comment #27 on issue 183 by hannibal218bc: Enhancement: find multiple

Sorry for not considering the source level... I wasn't really aware that
this is
critical for mobile devices.

As to the now-not-final classes, as I see it it is just two, QRCodeReader
and
Detector. Both classes will only receive only single method call
from "outside"
during the decoding of a whole image, so I guess the performance penalty is
not that
huge. BUT would it be possible to throw away the "extends ..." and create a
private
instance of the "super" class to reuse its methods? That way both classes
could be
final... The downside is that the "inner" methods would have to be public,
or both
classes in the same package again...

The find code duplicates about 50 lines, mainly the "for" loop. Since the
control
flow is changed a bit (no "done" flag, not iSkip modification, no check for
multiple
confirmed centers) it will probably be not easy to press everything into
one method,
and it would need some additional ifs.

codesite...@google.com

unread,
May 5, 2009, 5:52:46 AM5/5/09
to zx...@googlegroups.com

Comment #28 on issue 183 by srowen: Enhancement: find multiple barcode into
an image
http://code.google.com/p/zxing/issues/detail?id=183

OK, committed. Try it out and see that it works?

codesite...@google.com

unread,
May 5, 2009, 7:16:11 AM5/5/09
to zx...@googlegroups.com

Comment #29 on issue 183 by hannibal218bc: Enhancement: find multiple

Thank you, works as advertised. :-)

There is one thing I noticed, which is probably not related to this change
but to
some commit in between?, is:

ERR File: IMG_1118.JPG exception: java.lang.ArrayIndexOutOfBoundsException:
405
java.lang.ArrayIndexOutOfBoundsException: 405
at com.google.zxing.common.BitMatrix.get(BitMatrix.java:60)
at
com.google.zxing.qrcode.decoder.BitMatrixParser.readCodewords(BitMatrixParser.java:185)
at com.google.zxing.qrcode.decoder.Decoder.decode(Decoder.java:76)


This seems to happen when there are fragments of a QR code on the edge of
the image
and "peeking out". (In this image, there is one code that has its finders
on the
image, but the alignment pattern already is out).

This hasn't happened with the Apr-28 version. I'd searched the svn history,
but I
don't really know what or where to look for...

codesite...@google.com

unread,
May 5, 2009, 8:22:14 AM5/5/09
to zx...@googlegroups.com

Comment #30 on issue 183 by srowen: Enhancement: find multiple barcode into
an image
http://code.google.com/p/zxing/issues/detail?id=183

Hmm can you post the image so I can debug? that is weird.

codesite...@google.com

unread,
May 5, 2009, 9:57:24 AM5/5/09
to zx...@googlegroups.com

Comment #31 on issue 183 by hannibal218bc: Enhancement: find multiple

Thank you for investigating this - image attached. It's not only this one,
it happens
with some other images of the same series, too.

Attachments:
IMG_1118.JPG 3.6 MB

codesite...@google.com

unread,
May 5, 2009, 4:27:04 PM5/5/09
to zx...@googlegroups.com

Comment #32 on issue 183 by srowen: Enhancement: find multiple barcode into
an image
http://code.google.com/p/zxing/issues/detail?id=183

How are you scanning the barcode -- what code are you running? Over here I
am just
getting no barcode found.

codesite...@google.com

unread,
May 5, 2009, 6:44:58 PM5/5/09
to zx...@googlegroups.com

Comment #33 on issue 183 by hannibal218bc: Enhancement: find multiple

Here's a minimalistic test snippet. It uses -- of course ;-] -- the new
QRCodeMultiReader class. The default QRCodeReader fails because the
FinderPatternFinder selects an inappriopriate "selectBestPatterns".

=== cut ===
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Hashtable;

import javax.imageio.ImageIO;

import com.google.zxing.DecodeHintType;
import com.google.zxing.Result;
import com.google.zxing.client.j2se.BufferedImageMonochromeBitmapSource;
import com.google.zxing.multi.qrcode.QRCodeMultiReader;

public class Test183 {
public static void main(final String[] args){
try{
final QRCodeMultiReader reader = new QRCodeMultiReader();

Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType,
Object>();
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);

final BufferedImage image = ImageIO.read(new File("IMG_1118.JPG"));

final Result[] results = reader.decodeMultiple(new
BufferedImageMonochromeBitmapSource(image), hints);

System.out.println("DecodeMulti
DONE, "+(results!=null?results.length:0)+" results");
}catch(Exception e){
e.printStackTrace();
}
}
}
=== cut ===

Output:

java.lang.ArrayIndexOutOfBoundsException: 405
at com.google.zxing.common.BitMatrix.get(BitMatrix.java:60)
at
com.google.zxing.qrcode.decoder.BitMatrixParser.readCodewords(BitMatrixParser.java:185)
at com.google.zxing.qrcode.decoder.Decoder.decode(Decoder.java:76)

at
com.google.zxing.multi.qrcode.QRCodeMultiReader.decodeMultiple(QRCodeMultiReader.java:53)
at Test183.main(Test183.java:22)


The Java environment is (on Gentoo Linux):
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Server VM (build 11.3-b02, mixed mode)

codesite...@google.com

unread,
May 6, 2009, 4:26:45 AM5/6/09
to zx...@googlegroups.com

Comment #34 on issue 183 by gentuser: Enhancement: find multiple barcode

Same here

run:
java.lang.ArrayIndexOutOfBoundsException: 614


at com.google.zxing.common.BitMatrix.get(BitMatrix.java:60)
at
com.google.zxing.qrcode.decoder.BitMatrixParser.readCodewords(BitMatrixParser.java:185)
at com.google.zxing.qrcode.decoder.Decoder.decode(Decoder.java:76)
at
com.google.zxing.multi.qrcode.QRCodeMultiReader.decodeMultiple(QRCodeMultiReader.java:53)

at javaapplication3.Main.main(Main.java:29)
Using Gentoo Linux and Ubuntu linux

java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)

codesite...@google.com

unread,
May 6, 2009, 4:30:46 AM5/6/09
to zx...@googlegroups.com

Comment #35 on issue 183 by gentuser: Enhancement: find multiple barcode

Same here

run:
java.lang.ArrayIndexOutOfBoundsException: 614
at com.google.zxing.common.BitMatrix.get(BitMatrix.java:60)
at
com.google.zxing.qrcode.decoder.BitMatrixParser.readCodewords(BitMatrixParser.java:185)
at com.google.zxing.qrcode.decoder.Decoder.decode(Decoder.java:76)
at
com.google.zxing.multi.qrcode.QRCodeMultiReader.decodeMultiple(QRCodeMultiReader.java:53)
at javaapplication3.Main.main(Main.java:29)
Using Gentoo Linux and Ubuntu linux

java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)

Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)

codesite...@google.com

unread,
May 6, 2009, 8:08:14 AM5/6/09
to zx...@googlegroups.com

Comment #36 on issue 183 by srowen: Enhancement: find multiple barcode into
an image
http://code.google.com/p/zxing/issues/detail?id=183

Thanks, I have opened Issue 189 to track this separately. This is a good
report.

At first glance I am not sure what is going on. It occurs well after the
barcode has
been successfully read from the image, and during the phase when it decodes
the
barcode. That makes it more surprising to me. I will investigate.

codesite...@google.com

unread,
May 6, 2009, 8:22:20 AM5/6/09
to zx...@googlegroups.com

Comment #37 on issue 183 by gentuser: Enhancement: find multiple barcode

This seems occur with other images too..

Attachments:
50.png 31.5 KB

codesite...@google.com

unread,
May 6, 2009, 2:01:28 PM5/6/09
to zx...@googlegroups.com

Comment #38 on issue 183 by hannibal218bc: Enhancement: find multiple

One possible workaround specific to the QRCode Multi Decoder is to
catch(Exception)
in QRCodeMultiReader line 60 instead of only ReaderException.
However, I'm not sure whether it is actually a good idea to silently
discard any
exception that may fly in...

suggestion:
}catch(ReaderException e){
// silently discard
} catch (Exception re) {
re.printStackTrace();
}


When applying this change, the images give the following results:
IMG_1118.JPG: 4 good, 1 ArrayIndex...
50.png: 3 good, 3 ArrayIndex...

john immanuel

unread,
Dec 14, 2017, 2:28:58 AM12/14/17
to zxing
Hi,

In Ontario driving license there is two barcodes (code39 and PDF417), my code reads only code 39 and I am not getting the full information. It does not reads PDF417.

If I tried an image with only PDF417 it works.

binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(ImageIO.read(in))));

MultiFormatReader multiFormatReader = new MultiFormatReader();
GenericMultipleBarcodeReader reader = new GenericMultipleBarcodeReader(
multiFormatReader);
Hashtable<DecodeHintType, Object> decodeHints = new Hashtable<DecodeHintType, Object>();
decodeHints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
decodeHints.put(DecodeHintType.POSSIBLE_FORMATS, EnumSet.allOf(BarcodeFormat.class));


Result[] results = reader.decodeMultiple(binaryBitmap, decodeHints);
for (Result result : results) {
ParsedResult parsedResult = ResultParser.parseResult(result);
System.out.println(" (format: "
+ result.getBarcodeFormat() + ", type: "
+ parsedResult.getType() + "):\nRaw result:\n"
+ result.getText() + "\nParsed result:\n"
+ parsedResult.getDisplayResult());
System.out.println("Found " + result.getResultPoints().length + " result points.");
for (int i = 0; i < result.getResultPoints().length; i++) {
ResultPoint rp = result.getResultPoints()[i];
System.out.println(" Point " + i + ": (" + rp.getX() + ',' + rp.getY() + ')');
}
}

Reply all
Reply to author
Forward
0 new messages