finding 1 particular barcode test case interesting

39 views
Skip to first unread message

chance

unread,
May 22, 2015, 1:52:02 PM5/22/15
to zx...@googlegroups.com
I've got a set of tests (on the order of 50), and all except 1 are
working. I'm not all that upset about this case failing, the scan
quality is pretty poor. However, if we bring up a suitably zoomed
image in gimp, and point the Barcode Scanner at it, it works!

Is this expected? Does Barcode Scanner have extra goodies in it? Or
does jitter from holding the phone actually help things if you give it
enough time?

Or am I doing something wrong? Money code is approximately :

public static String getWorkTicketNumberWithBarcode(BufferedImage image)
{
try
{
MultiFormatReader multiFormatReader = new MultiFormatReader();
Map<DecodeHintType, Object> tmpHintsMap = new EnumMap<DecodeHintType, Object>(DecodeHintType.class);
tmpHintsMap.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
tmpHintsMap.put(DecodeHintType.POSSIBLE_FORMATS, EnumSet.of(BarcodeFormat.CODE_128));

BinaryBitmap workTicketBinBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(image)));
Result decodeResult = multiFormatReader.decode(workTicketBinBitmap,tmpHintsMap);
String workTicketNumber = decodeResult.getText();

logger.info("Found work ticket number: " + workTicketNumber);
return workTicketNumber;
}
catch (Exception e)
{
logger.error("Unable to decode work ticket.", e);
return null;
}
}

Attached is image in question. It should decode into the string "1020-23460".
ticket14.png.gz

Lachezar Dobrev

unread,
May 25, 2015, 4:53:50 AM5/25/15
to chance, zxing
Hello.
The code does not look bad. Although if you're only scanning for a
particular bar-code you could skip the multi-format wrapper and use
the designated bar-code reader, in your case the
com.google.zxing.oned.Code128Reader, but that is up to you, and has
little effect.

Your observation is not wrong. ZXing has been designed to perform
quick scans with less-than-perfect success rate, and instead perform
large number of successive tests since it works with a video source.
That does make it less-reliable when using a single image to decode
(like those from a document scanner for instance). Hence sometimes
distorting the original image may actually yield better results.
So it may prove to be beneficial to perform a combination of
distortions on the image and perform multiple attempts to scan the
image.
I commonly make various combinations of scaling-down and blurring
the image, which have proved quite effective in decoding bar-codes
(well QR codes) embedded in scanned documents.

In fact I tried your image with a 3x3 blur and it decoded fine (with
the TRY_HARDER hint).

If your application is designed to run on a regular machine (not
phone and not tablet) you might consider adding distortions and giving
it a second attempt (or third, or fourth).
> --
> 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.
Reply all
Reply to author
Forward
0 new messages