0

First I am not sure if this is an array. But this is pyzbar decoding an image of a QRcode

>>> from pyzbar.pyzbar import decode
>>> from PIL import Image
>>> barcode = decode(Image.open('qr111.png'))
>>> print(barcode)
[Decoded(data='812', type='QRCODE', rect=Rect(left=1166, top=306, width=336, height=336), polygon=[Point(x=1166, y=306), Point(x=1166, y=642), Point(x=1502, y=642), Point(x=1502, y=306)])]

I want to retrieve specifically the value "812" of data, how do I do it? I tried print(barcode[Decoded(data)]) to no avail.

asked May 29, 2018 at 9:10
1
  • 1
    Try print(barcode[0].data). Decoded looks like name of type in that case, and outer [..] looks like a list. Commented May 29, 2018 at 9:14

1 Answer 1

2

This will get you what you want:

barcode[0].data

It's all in the source code.

answered May 29, 2018 at 9:15
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.