-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error decode UTF-8 character 'â' #18
Comments
Hi, @Eric-Canas I am using
|
I have been trying to replicate the error in Windows, Amazon Linux and Ubuntu 22.04, and I have not been able to reproduce it :( The error should be replicable by running: >>> 'テ「'.encode('shift-jis').decode('utf-8')
'â' Does this code also breaks for you? My best guess is that It must be related with regional configuration of the OS, but I can not ensure that as I have not been able to replicate the error :( The problem is related to how python encode and decode plain strings with special characters. As that's the line that is giving you the warning: |
I have trying my code in the google colab and given result the same on my computer. And I have checked result (b'\x8e\xa3' ) of pyzbar my program had different your result (b'\xc3\xa2') : |
Hi! Sorry for the inconvenience, I oversimplified the error. I have been researching it thanks to your Google Colab, and I found that problem was that Windows and Linux does not use the same decoding. So, while default "utf-8" pyzbar decoding was 'テ「' for Windows, it was '璽' for Linux. I did a large experimentation of shift-jis vs other encodings, and "Big5" is the one that gave me the correct decoding results for all characters on Linux systems, as shift-jis was for Windows systems (It gives same decoding that shift-jis for all cases where shift-jis works, and correct results for those cases where it fails on Linux). I have uploaded an update that selects one or the other encoding as default, depending on your OS ("Big5" fails on a lot of characters on Windows :( ). I have tested it on your Google Colab, and that's producing expected results now. You can upgrade it by Thanks a lot for your warning! |
Hi @Eric-Canas, I have checked your solution and one that gave correct decoding results on my computer. |
Hi @Eric-Canas , I have check QReader(reencode_to="big5") with character 'â' then gaven correct result. When i have checked lagre data with QReader(reencode_to="big5") then I have many same error. import json from qreader import QReader image_path = "my_image.png" qreader = QReader(model_size='n',reencode_to='big5') for i in data: |
Hi! Thanks for your test data. I'm still testing, it seems that there are some entries quite difficult to decode. By the moment I can tell you that most of your errors should dissapear this way:
But not all of them. To easily replicate the error, there should be a way to decode But I can't find any charset that works. That's the direct byte detection pyzbar gets from the qr generated by qrcode for this entry. And I can't find any single nor double encoding way of decoding it correctly. Sorry, I'll update you if a find an alternative. |
Hi, i same issue. |
Hi, Did someone solve this problem or have any approach to handle this case ? Thank you! |
Hello i have a same issue . def read_qr_code_2(image_path):
# Create a QReader instance
qreader = QReader(model_size = 's', min_confidence = 0.5, reencode_to = 'utf-8')
# Get the image that contains the QR code
image = cv2.cvtColor(cv2.imread(image_path), cv2.COLOR_BGR2RGB)
# Use the detect_and_decode function to get the decoded QR data
decoded_text = qreader.detect_and_decode(image=image)
print(decoded_text) |
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 qreader import QReader
from PIL import Image
import qrcode
image_path = "my_image.png"
data = 'â'
print(f'data = {data}')
img = qrcode.make(data)
img.save(image_path)
img = cv2.imread(image_path)
result = qreader.detect_and_decode(image=img)
print(f"result = {result[0]}")
The text was updated successfully, but these errors were encountered: