Search code examples
pythonpython-3.xbarcodebarcode-scanner

Why I can't read multiple barcode with pyzbar?


I'm trying to use pyzbar to read multiple barcode, however it seems like I can't read multiple instead of only one big bounding boxes.enter image description here


Solution

  • When you call pyzbar.decode it will decode all 1D barcodes in your image. For example:

    enter image description here

    from pyzbar.pyzbar import decode
    from PIL import Image
    
    for bar in decode(Image.open('benchmark.jpg')):
        print(bar.data)
    

    will print out

    b'12345678'
    b'12345678'
    b'0000123456784'
    

    However in your case all barcodes are identical so pyzbar just returns a list with a single element. It would work if they were different however.