1

I am working on a Python project where I need to read PDF417 barcodes from user IDs. I am using Pyzbar library and PIL module to decode the barcodes from images. However, when I run the code, it returns an empty array even though the barcode is present in the image. I am not sure what the problem is.

To verify that the barcode is readable, I uploaded the same image to an online barcode reader This Site, which was able to display the results correctly.

Here's the code I am using:

from pyzbar import pyzbar
from PIL import Image as PIL

# Load image
image = PIL.open('b.jpg')

# Decode barcode
barcodes = pyzbar.decode(image, symbols=[pyzbar.ZBarSymbol.PDF417])
print(barcodes)

# Print barcode data
for barcode in barcodes:
    print(barcode.data.decode('utf-8'))


What could be causing the Pyzbar library to not decode the PDF417 barcode from the image? Is there something wrong with the code or the library itself? How can I fix the issue and successfully read the barcodes using Python?

Mr.Bhanuka
  • 11
  • 2
  • "*the barcode is present in the image*" We don't have your image to reproduce your examlpe, please [edit](https://stackoverflow.com/posts/76208654/edit) your question to provide a [MWE](https://stackoverflow.com/help/minimal-reproducible-example) including your barcode image. – Bilal May 11 '23 at 15:28

0 Answers0