Skip to content

Instantly share code, notes, and snippets.

@tovask
Created December 22, 2016 16:21
Show Gist options
  • Save tovask/6c3362e350d25cfc637cd4627f967ae9 to your computer and use it in GitHub Desktop.
Save tovask/6c3362e350d25cfc637cd4627f967ae9 to your computer and use it in GitHub Desktop.
"""
Decode all QR-code images in a directory.
Dependencies:
sudo pip install pypng
sudo apt-get update
sudo apt-get install libzbar-dev
sudo pip install zbar
sudo pip install pillow
sudo pip install qrtools
"""
import qrtools
from os import listdir
from os.path import isfile, join
mypath = "encoded"
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
#print len(onlyfiles)
#onlyfiles = onlyfiles[:10]
#print onlyfiles
qr = qrtools.QR()
for f in onlyfiles:
try:
qr.decode(join(mypath, f))
print qr.data, f
except:
print "Exception at "+f+"\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment