I have hundreds of pictures with qr codes (sometimes there are 0, 1, 2 or more qr codes on one page...but they are always in one line). I want to decode the qr codes from left to right. My idea is to split the qr codes in separate images.
Does somebody know a Linux (or Python) solution for this problem?
The order I want is: url1, url2, url3, url4, url5, url6.
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, ZBarSymboltry:from PIL import Image
except:cmd = ('py -m pip install "Pillow"')os.system(cmd)from PIL import Imagedecoded = 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 codeqr_dic[x] = qr[0] # The Data stored in the QR codefor qr in sorted(qr_dic.keys()):print(qr_dic[qr])
Output:
b'url1'
b'url2'
b'url3'
b'url4'
b'url5'