ZXing library barcode decoding failed

86 views
Skip to first unread message

Test User

unread,
Oct 5, 2018, 5:51:14 AM10/5/18
to zxing
Using Zxing library in java to decode barcode present in TIFF file, not working for few TIFF images though it contains the barcode.
I have attached 2 TIFF for which decoding failed.
Below code is used to check barcode in TIFF :

public boolean isBarcodePresent(String tiffFile) throws IOException{
boolean isBarcodePresent = false;
BufferedImage bufferedTifImage = ImageIO.read(new File(tiffFile));

LuminanceSource source = new BufferedImageLuminanceSource(bufferedTifImage);

BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));

Reader reader = new MultiFormatReader();

Result result = null;

try {

Map<DecodeHintType,Object> tmpHintsMap = new EnumMap<DecodeHintType, Object>(DecodeHintType.class);

tmpHintsMap.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);

result = reader.decode(bitmap, tmpHintsMap);

} catch (Exception e) {

log.error("Exception while reading barcode", e);

isBarcodePresent = false;

}

if (result != null && result.getText().equalsIgnoreCase("TRANSACTION")) {

isBarcodePresent = true;

}
return isBarcodePresent;

}

1.tif
2.tif
Reply all
Reply to author
Forward
0 new messages