本文整理汇总了Python中qrtools.QR.decode方法的典型用法代码示例。如果您正苦于以下问题:Python QR.decode方法的具体用法?Python QR.decode怎么用?Python QR.decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qrtools.QR
的用法示例。
在下文中一共展示了QR.decode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scanadd
# 需要导入模块: from qrtools import QR [as 别名]
# 或者: from qrtools.QR import decode [as 别名]
def scanadd(name):
myCode = QR(filename=name)
if myCode.decode():
if myCode.data_type == "text":
print "worked"
retval=""
add = False
start = True
for x in myCode.data:
if x in "13" and start:
add = True
start = False
retval+=x
elif add and x in "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ":
retval+=x
else:
add=False
print "raw",myCode.data
return retval
#aystit(retval, amt)
else:
print "That isn't text you tricky trickster"
else:
print "I can't decode that. Sorry."
示例2: decodeFile
# 需要导入模块: from qrtools import QR [as 别名]
# 或者: from qrtools.QR import decode [as 别名]
def decodeFile(self, fn=None):
if not fn:
fn = unicode(QtGui.QFileDialog.getOpenFileName(
self,
u'Open QRCode',
filter=u'Images (*.png *.jpg);; All Files (*.*)'
)
)
if os.path.isfile(fn):
qr = QR(filename=fn)
if qr.decode():
self.showInfo(qr)
else:
QtGui.QMessageBox.information(
self,
u'Decode File',
u'No QRCode could be found in file: <b>%s</b>.' % fn
)
else:
QtGui.QMessageBox.information(
self,
u"Decode from file",
u"The file <b>%s</b> doesn't exist." %
os.path.abspath(fn),
QtGui.QMessageBox.Ok
)
示例3: decode_image
# 需要导入模块: from qrtools import QR [as 别名]
# 或者: from qrtools.QR import decode [as 别名]
def decode_image(filename="default.png"):
"""default.png is a sample image. for more qr code images, see http://qrcode.kaywa.com/"""
my_code = QR(filename=os.path.dirname(os.path.abspath(__file__)) + "/" + filename)
if my_code.decode():
print my_code.data
return my_code.data
else:
return None
示例4: decodeKey
# 需要导入模块: from qrtools import QR [as 别名]
# 或者: from qrtools.QR import decode [as 别名]
def decodeKey(file):
decCode = QR(filename=file)
if decCode.decode():
key = decCode.data
int_key = []
for b in key.split('/'):
int_key.append(int(b))
return int_key
示例5: decodeQRCode
# 需要导入模块: from qrtools import QR [as 别名]
# 或者: from qrtools.QR import decode [as 别名]
def decodeQRCode(fileName, path=""):
"""expects fileName is .jpg"""
myCode = QR(filename = path + fileName)
if myCode.decode():
print "decoderen qr gelukt"
return myCode.data
else:
print "decoderen qr gefaald"
return False
示例6: decodeAES
# 需要导入模块: from qrtools import QR [as 别名]
# 或者: from qrtools.QR import decode [as 别名]
def decodeAES(key, file):
if isinstance(key, str):
int_key = hexToKey(key)
elif isinstance(key, list):
int_key = key[:]
AESqr = QR(filename=file)
if AESqr.decode():
plaintext = dAES.decrypt(AESqr.data, int_key)
return plaintext
示例7: get_qr_code
# 需要导入模块: from qrtools import QR [as 别名]
# 或者: from qrtools.QR import decode [as 别名]
def get_qr_code(image_filename):
""" Return True if the given image is a front page (based on a QR code)
or false otherwise. The QR code must contain FRONT_PAGE_CODE to indicate
that the page is a front page. """
scanner = QR(filename=image_filename)
if scanner.decode():
data = scanner.data
return data
else:
return None
示例8: qrimg
# 需要导入模块: from qrtools import QR [as 别名]
# 或者: from qrtools.QR import decode [as 别名]
def qrimg(lines,filename):
lines = unicode(lines, "utf-8")
img=Image.new("RGBA", (380,380),(255,255,255))
draw = ImageDraw.Draw(img)
y_text =8
for line in lines.splitlines():
width, height = font.getsize(line)
draw.text((10,y_text),line,(0,0,0), font=font)
y_text +=height
draw = ImageDraw.Draw(img)
#img = img.resize((380,420))
img.save(filename)
thedata = QR(filename=filename)
if thedata.decode():
return thedata.data
else:
return "Error: " + filename + " "
示例9: decodeFile
# 需要导入模块: from qrtools import QR [as 别名]
# 或者: from qrtools.QR import decode [as 别名]
def decodeFile(self, fn=None):
if not fn:
fn = unicode(
QtGui.QFileDialog.getOpenFileName(
self, self.trUtf8("Open QRCode"), filter=self.trUtf8("Images (*.png *.jpg);; All Files (*.*)")
)
)
if os.path.isfile(fn):
qr = QR(filename=fn)
if qr.decode():
self.showInfo(qr)
else:
QtGui.QMessageBox.information(
self,
self.trUtf8("Decode File"),
unicode(self.trUtf8("No QRCode could be found in file: <b>%s</b>.")) % fn,
)
示例10: btnTakePhotoClick
# 需要导入模块: from qrtools import QR [as 别名]
# 或者: from qrtools.QR import decode [as 别名]
def btnTakePhotoClick(self, event):
qr = QR()
i = 0
while qr.data == "NULL":
#while i == 0:
_filename = '/home/pi/cpi/camera' + str(i) + '.jpg'
camera = picamera.PiCamera()
camera.resolution = (300, 300)
camera.capture(_filename)
print "gecaptured: " + _filename
z = qr.decode(_filename)
print z
bm = wx.Image(_filename, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
#bitmap = wx.Bitmap(QR_IMAGE_FILE)
#bitmap = self.scale_bitmap(bitmap, 300, 300)
#control = wx.StaticBitmap(self, -1, bitmap)
#control.SetPosition((10, 10))
self.imgQROutgoing.SetBitmap(bm)
self.textImageWhatToDo.Label="Message: " + qr.data
#self.Refresh()
self.Update()
print "refreshed"
#im = Image.open('/home/pi/cpi/camera' + str(i) + '.jpg')
#pho = ImageTk.PhotoImage(im)
#label = Label(image = pho)
#label.image = pho
#label.pack()
##root.update()
###frame.update()
#self.ph.image = pho
print "bild camera" + str(i) + ".jpg angezeigt"
time.sleep(1)
camera.close()
#qr.destroy()
i = i + 1
print "i ist jetzt: " + str(i)
print "--------------------------------------"
示例11: readqr
# 需要导入模块: from qrtools import QR [as 别名]
# 或者: from qrtools.QR import decode [as 别名]
def readqr(data):
filename = "%s%s.bmp" %(imgpath,str(uuid.uuid4()))
##qr mappings
cmap = {'0': (255,255,255),
'1': (0,0,0)}
## clean up the data
length = len(data.split("\n"))
data = data.replace("\n","")
##build image
rawdata = [cmap[letter] for letter in data]
img = Image.new('RGB', (length, len(data)//length), "white")
img.putdata(rawdata)
img.save(filename, 'BMP')
##decode image
myCode = QR(filename=filename)
if myCode.decode():
text=myCode.data
return text.lower()
else:
return False
示例12: check_image_qr
# 需要导入模块: from qrtools import QR [as 别名]
# 或者: from qrtools.QR import decode [as 别名]
def check_image_qr(self, path):
myCode = QR(filename=path)
if myCode.decode():
self.qr_link = myCode.data_to_string()
self.copy_link.set_sensitive(True)
alert = NotifyAlert(10)
alert.props.title = _("Code found")
alert.props.msg = _("Click on toolbar button for "
"copy link to clipboard.")
alert.connect("response", lambda x,
y: self.activity.remove_alert(x))
self.activity.add_alert(alert)
else:
self.qr_link = None
self.copy_link.set_sensitive(False)
alert = NotifyAlert(10)
alert.props.title = _("Code not found")
alert.props.msg = _("Try again, please focus the Qr "
"Code in the camera.")
alert.connect("response", lambda x,
y: self.activity.remove_alert(x))
self.activity.add_alert(alert)
self.stop_play.set_sensitive(False)
示例13: QR
# 需要导入模块: from qrtools import QR [as 别名]
# 或者: from qrtools.QR import decode [as 别名]
#!/usr/bin/env python
# encoding: utf-8
from qrtools import QR
if __name__ == '__main__':
qr = QR(filename='./qr-fix.png')
if qr.decode():
print qr.data
示例14: qrdecode
# 需要导入模块: from qrtools import QR [as 别名]
# 或者: from qrtools.QR import decode [as 别名]
def qrdecode(filename):
qr = QR()
qr.decode(filename)
return qr.data
示例15: int
# 需要导入模块: from qrtools import QR [as 别名]
# 或者: from qrtools.QR import decode [as 别名]
resolution_level = 9
num_cases = int(sys.stdin.readline())
for num_case in range(num_cases):
text_squares = sys.stdin.readline().rstrip('\r\n').split()
squares = [ parse_square(s) for s in text_squares ]
s = squares[0]
for i in range(1, len(squares)):
s = add_squares(s, squares[i])
qrname = u'case%d_sum.png' % (num_case + 1)
create_png(qrname, s, resolution_level)
myCode = QR(filename=qrname)
if myCode.decode():
#m = md5.new()
#m.update(myCode.data_to_string())
#print m.hexdigest()
secret = myCode.data_to_string()
# Strip non iso-8859-1 characters
secret = secret.decode('utf-8')
secret = secret.encode('iso-8859-1', 'ignore')
print secret