Skip to main content
  1. About
  2. For Teams
Asked
Viewed 473 times
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.

1
  • 1
    Try print(barcode[0].data). Decoded looks like name of type in that case, and outer [..] looks like a list.
    yeputons
    –  yeputons
    2018-05-29 09:14:47 +00:00
    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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.