Not a able to decode the barcode of type ITF or 8/I2OF5

213 views
Skip to first unread message

prasad devadass

unread,
Apr 30, 2014, 12:38:49 PM4/30/14
to zx...@googlegroups.com, sro...@gmail.com
I am using Zxing API to decode the barcode text from the attached file .

When the image is parsed by few barcode decoding website I am getting the proper text as below
Barcode type: 8/I2OF5
Barcode value: 100024

But when the same barcode is decode against Zxing API returns the following output
BarCodeText::::::10028847
BarCodeFormat:::UPC_E

The similar behavior happens for most the images with ITF format and wrongly decoded as UPC_E for some reason by Zxing API

Source Sample :
try
{
Reader reader = new MultiFormatReader();
LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(
new GlobalHistogramBinarizer(source));
Collection<Result> results = new ArrayList<Result>(2);

try {
// Look for multiple barcodes
MultipleBarcodeReader multiReader = new GenericMultipleBarcodeReader(
reader);
Result[] theResults = multiReader.decodeMultiple(bitmap,
HINTS);

if (theResults != null) {
results.addAll(Arrays.asList(theResults));
}
System.err.println("Collection Size:::" + results.size());
for (Result result : results) {
System.err.println("BarCodeText::::::"
+ result.getText() + "\nBarCodeFormat:::"
+ result.getBarcodeFormat());

Can you someone let me know what is the wrong with code or the API behaviour

test.jpg

prasad devadass

unread,
Apr 30, 2014, 1:00:02 PM4/30/14
to zx...@googlegroups.com, sro...@gmail.com
I copied the bar code from the image and create a new jpeg and embedded the image and I ran the code it decode the bar code well . Some thing wrong with the image makes the decoder to read the data wrongly can some please explain why i m seeing this behavior
1.jpg

Sean Owen

unread,
Apr 30, 2014, 3:42:49 PM4/30/14
to zx...@googlegroups.com, sro...@gmail.com
Already answered you offline. You should scan for ITF only if you want to scan for only ITF barcodes. Looks at the DecodeHintType for POSSIBLE_FORMATS

prasad devadass

unread,
May 1, 2014, 12:35:30 PM5/1/14
to zx...@googlegroups.com, sro...@gmail.com
On Wednesday, April 30, 2014 3:42:49 PM UTC-4, Sean Owen wrote:
> Already answered you offline. You should scan for ITF only if you want to scan for only ITF barcodes. Looks at the DecodeHintType for POSSIBLE_FORMATS

Sean,
I have modified the code to use DecodeHintType = POSSIBLE_FORMATS and I added the hints for the reader as well in LINE 71

Also attaching the standalone and the image I am trying to decode

After running the code I get the barcode text as below
BarCodeText::::::10028847
BarCodeFormat:::UPC_E

Can please advise it is a wrong with code or with the image

BarCodeCreater.java
lynxx32.jpg

prasad devadass

unread,
May 1, 2014, 2:26:10 PM5/1/14
to zx...@googlegroups.com, sro...@gmail.com
I tried to decode the attached image http://zxing.org/w/decode.jspx I am getting the bar format as UPC_E which is actually a I2/5 format with text 100024
but zxing online decoder gives UPC_E with value 10028847

Can some one run a test on the sample attached image

lynxx32.jpg

Sean Owen

unread,
May 1, 2014, 2:36:41 PM5/1/14
to zx...@googlegroups.com, sro...@gmail.com
Prasad you have been told the answer three times:
Do not scan for anything but ITF.
Every example you show has this same problem. Fix that before replying again.

prasad devadass

unread,
May 1, 2014, 3:06:38 PM5/1/14
to zx...@googlegroups.com, sro...@gmail.com

Sean
I tried decoding the problematic image using the zxing online decoder at the following url
http://zxing.org/w/decode.jspx

I am not using my java code at all to decode the image . The online decoder itself is giving wrong values

Sean Owen

unread,
May 1, 2014, 3:12:09 PM5/1/14
to prasad devadass, ZXing
No, the online decoder is scanning for all formats, which is what you
shouldn't do, because you are likely to get a false positive for your
image.

prasad devadass

unread,
May 1, 2014, 3:52:21 PM5/1/14
to zx...@googlegroups.com, prasad devadass
On Thursday, May 1, 2014 3:12:09 PM UTC-4, Sean Owen wrote:
> No, the online decoder is scanning for all formats, which is what you
>
> shouldn't do, because you are likely to get a false positive for your
>
> image.
>
> Any one has the sample code to scan ITF barcode ?

prasad devadass

unread,
May 1, 2014, 4:10:37 PM5/1/14
to zx...@googlegroups.com, prasad devadass
Will this code work to decode ITF barcode ?
static final Hashtable<DecodeHintType, Object> HINTS;
static {
HINTS = new Hashtable<DecodeHintType, Object>(5);
Collection<BarcodeFormat> possibleFormats = new Vector<BarcodeFormat>();
HINTS.put(DecodeHintType.POSSIBLE_FORMATS, Boolean.TRUE);
HINTS.put(DecodeHintType.ALLOWED_LENGTHS, new int[] {8});
possibleFormats.add(BarcodeFormat.ITF);
}

public static void main(String[] args) throws IOException, NotFoundException, FormatException {
// TODO Auto-generated method stub
InputStream barCodeInputStream = new FileInputStream("c:\\temp\\barcode\\lynxximage\\lynxx32.jpg");
BufferedImage barCodeBufferedImage = ImageIO.read(barCodeInputStream);
LuminanceSource source = new BufferedImageLuminanceSource(barCodeBufferedImage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
ITFReader reader= new ITFReader();
Result result = reader.decode(bitmap, HINTS);
System.out.println("Barcode Format " + result.getBarcodeFormat());
System.out.println("Barcode text is " + result.getText());

}

Reply all
Reply to author
Forward
0 new messages