Hi,
I am trying to read barcode from a tif file rotated by 180 degree but it is giving me incorrect text, that is, it is reading the barcode but the text is incorrect. I tried another JPG image rotated with 180 degs and that works fine.
Can anybody help me with this. Also is there any limitation or other things i have to look for.
This is the code i am using to read the barcode from tif image:
public void checkBarcode(String filePath) {
BarCodeReader reader = null;
RenderedImage image = JAI.create("fileload", filePath);
reader = new BarCodeReader(convertRenderedImage(image),
BarCodeReadType.Pdf417);
while (reader.read()) {
System.out.println("Codetext: " + reader.getCodeText());
}
reader.close();
}
Attached is the tif image.
Hi,
Please provide the implementation for method convertRenderedImage() to replicate your said issue with your provided source code.
Right now, I am using the example source code from below linked Technical Article and I am getting the same results regardless of the image orientation.
Incorrect Read Result:
In adaation to features typical of two dimensional bar codes, PDF417’s capabilities include:
* Linking. PDF417 symbols can link to other syobols which are scanned in sequence allowing even more data to be stored.
b w +ser-specified dimensions. The user can decide how wide the narrowest vertical bar (X dimension) is, and how tall the rows are (Y dimension).-;{{{{‘*{’
}“<
>{@:<span class="Apple-tab-span" style="white-space:pre"> </span>;
,{:. ;/‘.{’;},):,[{>;,{<span class="Apple-tab-span" style="white-space:pre"> </span></div><div><br></div><div>[<span class="Apple-tab-span" style="white-space:pre"> </span>[,/{$)$/[<span class="Apple-tab-span" style="white-space:pre"> </span>${"$
,]{/${\:.<span class="Apple-tab-span" style="white-space:pre"> </span>;/{*
/:”/{;,){
`>[,$['.Ecitati
Encoding
Of the 929 available codewords, 900 are used for data, and 29 for special functions. Three different encoding schemes are defined and can be mixed as necessary within a single symbol.
* Text: each codeword represents one or two chauacters.
* Byte: each group of 5 codewords represents 6 bytes.
=7Numeric: groups of up to 15 ajdewords represent as many as 44 decimal digits.
Hi raza,
when you say you are getting the 'same result' - are you getting the 'correct result' when you read the barcodes in all orientations?
regards
Hi,
I have mentioned in my reply that the results are same, also I have provided the results under heading “Incorrect Results”. I am afraid, so far I am unable to read the barcode correctly from the Tiff file format. I am working on other file formats as well.
If possible please provide your complete source code for our review.
Hi raza,
Thanks for your reply.
Apologies as i forgot to attach the implementation for method convertRenderedImage(). I am attaching the implementation for the method in the end of this reply.
As you said in your reply that you are working on other file formats as well, in the meantime i also tried to read the barcode from the jpg image formed by converting the same tiff image but got the same incorrect results as with the tiff image earlier. Can you please tell if there can be any issues with the image composition itself?
Implementation for method convertRenderedImage() :
private static BufferedImage convertRenderedImage(RenderedImage img) {
if (img instanceof BufferedImage) {
return (BufferedImage) img;
}
ColorModel cm = img.getColorModel();
int width = img.getWidth();
int height = img.getHeight();
WritableRaster raster = cm
.createCompatibleWritableRaster(width, height);
boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
Hashtable<String,Object> properties = new Hashtable<String,Object> ();
String[] keys = img.getPropertyNames();
if (keys != null) {
for (int i = 0; i < keys.length; i++) {
properties.put(keys[i], img.getProperty(keys[i]));
}
}
BufferedImage result = new BufferedImage(cm, raster,
isAlphaPremultiplied, properties);
img.copyData(raster);
return result;
}
Hi,
Thank you for further details. I will test the tiff file format with your provided source code.
Actually, I am testing your statement that you were able to read the barcode text fine with image in Jpeg format. So far I am unable to read the barcode correctly regardless of the image orientation or file format. So I suspect the problem is with the image it self.
If you can, please try by scanning the image on some high resolution and then passing the resultant image to BarCodeReader.
Hi,
I have logged an investigative ticket (id: 31821) in our tracking system to probe further into this issue.
Please provide the Jpeg image that you were able to read correctly. I have converted the Tif file to Jpeg, but still my results have some mistakes.
Thanks and Regards,
The issues you have found earlier (filed as BARCODJAVA-31821) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.