Different results for 2 almost same images

30 views
Skip to first unread message

Yang

unread,
Mar 24, 2017, 6:27:25 AM3/24/17
to zxing
Hi everyone

I am trying to learn zxing, but I have a problem.

I have 2 almost same images (different file size), one is working, the other is not.

When I use zxing decoder online, 2 images are decoded correctly.

When I use my codes, I got a result = "@ ANSI 636012030001DL00000367DLDCAG DCBX DCDNONE DBA20200702 DCSCARINGI, DCTTOMMASO DBD20150630 DBB19630702 DBC1 DAYNONE DAU173 cm DAG19 ABINGER CRES, DAIETOBICOKE DAJON DAKM9B 2Y4 DAQC0597-74606-30702 DCFDG0395439 DCGCAN DCHNONE DCK*5911540*".

I also found this string from zxing decoder online, but zxing decoder online can get final result (something like C05977460630702).

So I am asking how can my codes to get final result?

Here is my codes

public static String decodeBarcode(String barcodePath)
{
BufferedImage image;
Result result = null;
try
{
image = ImageIO.read(new File(barcodePath));
if (image != null)
{
LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();
hints.put(DecodeHintType.CHARACTER_SET, "UTF-8");
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
hints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE);
result = new MultiFormatReader().decode(bitmap, hints);
}
return result.getText();
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
Reply all
Reply to author
Forward
0 new messages