1

I am trying to detect a barcode with pyzbar.

If get the following image up on my computer screen and scan it with my mobile phone camera then it is instantly able to provide me with the qr code information.

However, if I use Pyzbar to analyse the raw image file then I am not able to get any results.

enter image description here

How can I improve the accuracy of pyzbar?

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
knowledge_seeker
  • 811
  • 1
  • 8
  • 18
  • Can you post the code that you already tried? – rmutalik Dec 17 '22 at 04:32
  • 2
    Also, this is a Data Matrix code, not a QR code. You can tell by the pattern. A Data Matrix code always has an L track consisting of a solid dark line of two adjacent sides, and a clock track of alternating light-dark elements on the opposite adjacent sides. On PyPI, pyzbar's purpose is to "Read one-dimensional barcodes and QR codes from Python 2 and 3" (https://pypi.org/project/pyzbar/), which unfortunately does not include Data Matrix codes. However, you might have better luck with pylibdmtx, which is better suited (https://pypi.org/project/pylibdmtx/). – rmutalik Dec 17 '22 at 05:35
  • You could also try doing some pre-processing to your image to make it easier for the library to decode your image. This link recommends binarization: https://stackoverflow.com/questions/59617527/pyzbar-not-detecting-code93-barcodes – rmutalik Dec 17 '22 at 05:40

0 Answers0