Open Trantamhvbc opened 12 months ago
I'm having the same Issue using it with ã and ç, it seems to be a issue with latin characters image_binary = take_photo()
nparr = np.frombuffer(image_binary, np.uint8) img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
from PIL import Image
barcodes = decode(img)
** 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 get no issue using the qreader module so if anyone has issues with special characters I suggest using it until this module is updated
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}")