Barcode recognition in a multipage TIFF file

Hello,


I am testing your software reading all the posible barcodes present in a multipage TIFF file. This is my code:

public static void main(String[] args) throws Exception {
test.performTestAspose();
}

private void performTestAspose() throws Exception {
long t0 = System.currentTimeMillis();
License license = new License();
license.setLicense(“Z:\Aspose.BarCode.lic”);
SeekableStream ss = new FileSeekableStream(“Z:\tests\20130528092912147\20130528092912147.tif”);
ImageDecoder decoder = ImageCodec.createImageDecoder(“tiff”, ss, null);
int numPages = decoder.getNumPages();
com.aspose.barcoderecognition.BarCodeReader reader = null;
for(int j = 0; j < numPages; j++) {
PlanarImage op = PlanarImage.wrapRenderedImage(decoder.decodeAsRenderedImage(j));
BufferedImage bufferedImage = op.getAsBufferedImage();
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(bufferedImage, “png”, os);
InputStream is = new ByteArrayInputStream(os.toByteArray());
reader = new com.aspose.barcoderecognition.BarCodeReader(is, BarCodeReadType.Code128);
int barcodeCounter = 1;
while (reader.read()) {
System.out.println("------ Page " + (j + 1) + ". Number of code: " + barcodeCounter + “---------”);
System.out.println(“Code: " + reader.getCodeText() + “. Orientation: " + reader.getBarCodeOrientation());
System.out.println(“Points: (” + reader.getRegion().getPoints()[0] + “,” + reader.getRegion().getPoints()[1] +
“,” + reader.getRegion().getPoints()[2] + “,” + reader.getRegion().getPoints()[3] + “)”);
System.out.println(”-----------------------------------------\n”);
barcodeCounter++;
}
}
ss.close();
if (reader != null) {
reader.close();
}
long t1 = System.currentTimeMillis();
System.out.println(“Time performTestBufferedImage(): " + (t1 - t0) / 1000 + " seconds”);
}

I am experimenting different problems with the image I attach. The output of the program with this image is:

------ Page 3. Number of code: 1---------
Code: EASYAPANEXO. Orientation: 4
Points: ({X=2445,Y=912},{X=2657,Y=912},{X=2658,Y=1775},{X=2446,Y=1775})
-----------------------------------------

------ Page 3. Number of code: 2---------
Code: EASYAPANEXO. Orientation: 4
Points: ({X=727,Y=192},{X=1586,Y=192},{X=1586,Y=401},{X=727,Y=401})
-----------------------------------------

------ Page 3. Number of code: 3---------
Code: EASYAPANEXO. Orientation: 4
Points: ({X=263,Y=1825},{X=1122,Y=1823},{X=1122,Y=2034},{X=263,Y=2036})
-----------------------------------------

------ Page 3. Number of code: 4---------
Code: EASYAPANEXO. Orientation: 4
Points: ({X=9,Y=248},{X=219,Y=248},{X=218,Y=1110},{X=8,Y=1110})
-----------------------------------------

------ Page 4. Number of code: 1---------
Code: EASYAPANEXO. Orientation: 4
Points: ({X=2452,Y=919},{X=2662,Y=919},{X=2661,Y=1781},{X=2451,Y=1781})
-----------------------------------------

------ Page 4. Number of code: 2---------
Code: EASYAPANEXO. Orientation: 4
Points: ({X=735,Y=196},{X=1594,Y=197},{X=1594,Y=406},{X=735,Y=405})
-----------------------------------------

------ Page 4. Number of code: 3---------
Code: EASYAPANEXO. Orientation: 4
Points: ({X=268,Y=1829},{X=1127,Y=1829},{X=1127,Y=2038},{X=268,Y=2038})
-----------------------------------------

------ Page 5. Number of code: 1---------
Code: EA8@ZF V[EZL@Y. Orientation: 4
Points: ({X=2445,Y=915},{X=2657,Y=915},{X=2655,Y=1777},{X=2443,Y=1777})
-----------------------------------------

------ Page 6. Number of code: 1---------
Code: EASYAPANEXO. Orientation: 4
Points: ({X=2444,Y=914},{X=2655,Y=914},{X=2655,Y=1776},{X=2444,Y=1776})
-----------------------------------------

------ Page 6. Number of code: 2---------
Code: EASYAPANEXO. Orientation: 4
Points: ({X=726,Y=196},{X=1584,Y=195},{X=1584,Y=403},{X=726,Y=404})
-----------------------------------------

------ Page 6. Number of code: 3---------
Code: EASYAPANEXO. Orientation: 4
Points: ({X=260,Y=1828},{X=1121,Y=1826},{X=1121,Y=2037},{X=260,Y=2039})
-----------------------------------------

------ Page 6. Number of code: 4---------
Code: EASYAPANEXO. Orientation: 4
Points: ({X=7,Y=250},{X=216,Y=250},{X=216,Y=1112},{X=7,Y=1112})
-----------------------------------------

Time performTestBufferedImage(): 34 seconds


Barcodes present in pages 1 and 2 are not being recognized. Page 4 has 4 barcodes and only 3 are detected. Page 5 has quite bad quality so I guess this is normal. Why reader.getBarCodeOrientation() is always printing the value 4? Is not supposed to print the orientation of the barcode detected?

Another issue is the time invested to process the entire file. 34 seconds is quite a bit of time for a 6 page file. Am I doing something wrong? Is there anything I can do to speed up the whole process?



Thank you very much.

Hi Daniel,

Thanks for your inquiry. I'm sorry to share with you that you cannot detect the orientation of the detected bar code. Currently, we have included a fix to detect the orientation of a detected bar code in the Aspose.BarCode for .NET 5.5.0. When the Aspose.BarCode for Java 5.5.0 or higher will be ready for public use then this feature is present. I have logged this feature request for the sake of confirmation. This task has been logged under ticket id BARCODJAVA-33328 in our issue tracking system. Second, I managed to replicate the problem of recognition failure along with low performance. This problem has been logged under ticket id BARCODJAVA-33329 in our issue tracking system. Your issues have also been linked to this forum thread and you will be notified as soon as it is resolved and available for the public use. We're sorry for the inconvenience.
daniel.hernaez:
Is there anything I can do to speed up the whole process?
I have only one suggestion to cut the part where bar code resides as it seems always in the four sides of the bar code image. This can significantly speed up the processing as we will have to process only a small portion of the image.

PS: Aspose.BarCode for Java is fully auto-ported from .NET. Auto-porting allows us to maintain one code base and compile both the .NET and Java versions of our products from it. This benefits our customers because the two components are in sync and offer the same features.

Thanks for your reply. I am looking forward to the launching of the new version.



Hi Daniel,


Sure, we will keep you updated and let you know once it is fixed and available for public use.

The issues you have found earlier (filed as BARCODJAVA-33328) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Daniel,


Thank you for being patient. We have a good news for you that the issue id BARCODJAVA-33329 has now been resolved. If there is no issue in the QA phase, then this fix will be included in the next version of Aspose.BarCode for Java 6.9.0. We’ll inform you via this forum thread as soon as the new release is published.

The issues you have found earlier (filed as BARCODJAVA-33329) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.