You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a problem when I try using pyzbar to decode a QR image. But I had given result don't match data which I using qrcode make before.
this is my code:
from pyzbar.pyzbar import decode
from PIL import Image
from pyzbar.pyzbar import ZBarSymbol
import qrcode
image_path = "my_image.png"
data = 'â'
print(f'data = {data}')
img = qrcode.make(data)
img.save(image_path)
result = decode(Image.open(image_path),symbols=[ZBarSymbol.QRCODE])[0].data.decode("utf-8")
print(f"result = {result}")
The text was updated successfully, but these errors were encountered:
**** The QR code is the word Associação but pyzbar will return: data=b'Associa\xe7\x99\x9f\xe7\x93\x8ao *****
Thinking it was and encode-decode thing i tried doing several decodes but none return the right result, here is 2 of the most common encodings:
for barcode in barcodes:
try:
text = barcode[0].decode("latin-1") will return Associa��o
text = barcode[0].decode("utf-8") will return Associa癟瓊o
print(text)
except UnicodeDecodeError:
pass
I have a problem when I try using pyzbar to decode a QR image. But I had given result don't match data which I using qrcode make before.
this is my code:
from pyzbar.pyzbar import decode
from PIL import Image
from pyzbar.pyzbar import ZBarSymbol
import qrcode
image_path = "my_image.png"
data = 'â'
print(f'data = {data}')
img = qrcode.make(data)
img.save(image_path)
result = decode(Image.open(image_path),symbols=[ZBarSymbol.QRCODE])[0].data.decode("utf-8")
print(f"result = {result}")
The text was updated successfully, but these errors were encountered: