0

Using Zxing I tried to get barcode value from input image. I used the below code for getting barcode value.

        BufferedImage img = ImageIO.read(new File("C:/Demo_Project/Project/input.jpeg"));
        BufferedImage subimage = img.getSubimage(350, 300, 600, 600); // Since few posts mentioned like if filesize exceeds Zxing not works properly. I get subimage of barcode part from actual image. 

        LuminanceSource source = new BufferedImageLuminanceSource(subimage);
        BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
        Reader reader = new MultiFormatReader();
        Result result = reader.decode(bitmap);
        System.out.println("Barcode is ::"+result.getText());

Getting below exception,

com.google.zxing.NotFoundException .

Any fixes or other straight forward approaches to get barcode value from image files. My iamge files are actually taken in mobile camera which sizes close to 8MB. After getting subimage it become 4 to 10 KB still my image is not recognized properly. Any help would be appreciated. Of course, I have verified the sub-image contains the barcode. Please see the attachment.enter image description here

aarav
  • 230
  • 1
  • 4
  • 21
  • Why you're asking the same question twice? – Martin Zeitler Jul 05 '22 at 23:22
  • If the input source is a mobile camera, how do you know if the entire barcode is contained in the fixed area (350, 300), (600, 600)? Perhaps you should store the sub image on disk to verify that. It would also help others helping you, if you shared the input image for your test. – Harald K Jul 06 '22 at 07:52
  • Done. Barcode is found in sub image without missing any parts. Already verified it by writing image into disk. Thanks for your concern. @HaraldK – aarav Jul 06 '22 at 21:14

0 Answers0