Skip to content

Pyzbar has problems with detecting multiple barcodes #166

@Underest

Description

@Underest

Im using pyzbar to detect and decode barcodes in an jpg.
This jpg has multiple barcodes, but I need the Code128 one.
However, pyzbar only detects a sinlge barcode (its a Code39).
I have to cover the other barcode, in oder to detect the Code128 one.
I also tried to set the symbols argument to Code128, but doesnt work.

The original image:
2

The image with the covered barcode:
2_test

This is my code:

import cv2
import PIL.Image
import pyzbar.pyzbar as pyzbar

im = PIL.Image.open("2.jpg")
decoded = pyzbar.decode(im)
print(decoded)
im = PIL.Image.open("2.jpg")
decoded = pyzbar.decode(im,symbols=[pyzbar.ZBarSymbol.CODE128])
print(decoded)
im = PIL.Image.open("2_test.jpg")
decoded = pyzbar.decode(im)
print(decoded)

and Im getting following result:
[Decoded(data=b'0002', type='CODE39', rect=Rect(left=143, top=3296, width=6, height=0), polygon=[Point(x=143, y=3296), Point(x=149, y=3296)], quality=2, orientation='LEFT')]
[]
[Decoded(data=b'MO24-000830-1', type='CODE128', rect=Rect(left=154, top=6381, width=52, height=0), polygon=[Point(x=154, y=6381), Point(x=206, y=6381)], quality=10, orientation='LEFT')]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions