Decode Qr Codes With Python From Left To Right
I have a png with several qr codes which basically looks like this To decode the qr codes I use zbarlight. from PIL import Image import zbarlight file_path = './tests/qr_codes.pn
Solution 1:
I'm on windows, no way of testing on linux right now, but this appears to work as expected.
import sys, os
try:
from pyzbar.pyzbar import decode, ZBarSymbol
except:
cmd = ('py -m pip install "pyzbar"')
os.system(cmd)
from pyzbar.pyzbar import decode, ZBarSymbol
try:
from PIL import Image
except:
cmd = ('py -m pip install "Pillow"')
os.system(cmd)
from PIL import Image
decoded = decode(Image.open("C:/Temp/13AZQ.png"), symbols=[ZBarSymbol.QRCODE])
qr_dic = {}
for qr in decoded:
x = qr[2][0] # The Left position of the QR code
qr_dic[x] = qr[0] # The Data stored in the QR codefor qr insorted(qr_dic.keys()):
print(qr_dic[qr])
Output:
b'url1'
b'url2'
b'url3'
b'url4'
b'url5'
Post a Comment for "Decode Qr Codes With Python From Left To Right"