Comments (6)
Give more information about how you're decoding and encoding.
It's quite likely that the problem is on the encoding side; the encoder may not be correctly signalling the appropriate character set used for the Thai text using ECI.
Because many QR encoders (mis)behave by failing to mark the character set appropriately, ZXing includes logic to try to guess it, but it only knows how to distinguish UTF-8, ShiftJIS, and ISO-8859-1.
from python-zxing.
Hello Daniel, Sorry for late answer.
It's hard for me to answer your question. I'm just using Python 3, calling your method to get TEXT output from zxing and using zbar at the same time.
From what I see on google someone else had a similar problem:
zxing/zxing#708
Is it possible to force/set encoding via API?
Best regards,
David
from python-zxing.
It's hard for me to answer your question. I'm just using Python 3, calling your method to get TEXT output from zxing and using zbar at the same time.
Please show a complete working example of the code including how the barcode is encoded.
From what I see on google someone else had a similar problem: zxing/zxing#708
Yes. And as described in zxing/zxing#708 (comment), the problem is almost certainly with the encoding of the barcode.
In that case, the QR code was encoded in a Chinese character set, but without including an ECI code to inform the decoder of this, which contravenes the standard for how QR codes are supposed to be encoded.
My educated guess is that your case is similar: perhaps your barcode's contents are encoded in ISO-8859-11 (Thai charset) but also without including a corresponding ECI code.
Is it possible to force/set encoding via API?
In the encoder? I have no idea… it depends on what encoder you are using. 🤷♂️ (If the encoder is also ZXing, then yes it is certainly possible to set the correct ECI code.)
If you are asking whether there is a way to band-aid the ZXing decoder so that it uses the intended character set of the barcode, despite the absence of the required ECI code, then yes, you can do this in the Java API by passing a DecodeHintType.CHARACTER_SET to the reader.
There is no way to do this via the Python module currently. Patching the ZXing CLI to make it possible to specify a charset hint would make that possible.
from python-zxing.
Hello Daniel, Please find example of the source code and qrcode example below:
import os
import pyzbar.pyzbar as pyzbar
import zxing
from PIL import Image
reader = zxing.BarCodeReader()
def readBarcodeZ(im) :
decodedObjects = pyzbar.decode(im)
allbarcodes = []
for obj in decodedObjects:
allbarcodes.append (dict(type=obj.type, data=obj.data.decode('utf-8'), rect=obj.rect))
return allbarcodes
def readBarcodeX(im) :
decodedObject = reader.decode(im)
return decodedObject
imageFile = "qrcode-example-thai.png"
im = Image.open(imageFile)
im = im.convert('LA')
imBarcodeZ = readBarcodeZ(im)
imBarcodeX = readBarcodeX(imageFile)
print ("Zbar:", imBarcodeZ)
print ("Zxing:", imBarcodeX)
We use UTF-8 as the code page for encoding Thai characters. It looks like the easiest way is to just add an ECI code when creating qr code.
from python-zxing.
Daniel, Just update to my previous comment, I just ran a test on this site:
https://zxing.org/w/decode.jspx
and the decoded result looks good. Please find print screen below.
from python-zxing.
Hello Daniel, Please find example of the source code and qrcode example below:
When I run this code, with this example image, it works as intended… that's with 5bc2e3f, Python 3.6.9 on Linux with locale/charset of en_US.UTF-8
, and ZXing java libraries v3.4.1.
Zxing: BarCode(raw='TEST-THAI2-วันนี้คุณเป็นอย่างไรบ้าง?', parsed='TEST-THAI2-วันนี้คุณเป็นอย่างไรบ้าง?', format='QR_CODE', type='TEXT', points=[(231.5, 522.0), (231.5, 308.5), (445.0, 308.5), (423.5, 500.5)])
I'm not sure what you're expecting me to be able to tell you. You haven't given me enough information.
- You didn't include the output of your example code. It works for me. Does it not work for you? I have no idea. 🤷♂️
- The code and barcode image you showed are clearly not the same as the ones from for the initial post. I can't read barcodes or interpret source code which I've never seen. 🤷♂️
from python-zxing.
Related Issues (20)
- Cannot install from tarball HOT 1
- Command-line interface HOT 4
- data matrix generator HOT 1
- Fix TravisCI test failure for python 3.7, 3.8
- read multiple barcodes? HOT 3
- raw and parsed decode compatibility with ZXing HOT 5
- Use jpype for wrapper? HOT 2
- how to get rawByte from qr code? HOT 2
- How to input image array instead of filename to read QR code? HOT 3
- utf-8 codec decoding error HOT 3
- How to get QR Code version, error correction level, and mask? HOT 4
- Can't find the code when there are other content in the image HOT 1
- Different results from online decoder HOT 2
- ZXing does not decode some QR images HOT 2
- UnboundLocalError: local variable 'bc' referenced before assignment HOT 4
- Issues in decoding PDF 417 format Barcodes HOT 2
- I don't know what the problem is HOT 4
- what's the difference between raw and parsed results? HOT 1
- Java binary specified does not exist HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-zxing.