Python 对使用pylibdmtx编码的base256数据矩阵进行解码时出错
我正在尝试成功解码使用pylibdmtx进行base256编码的数据矩阵条形码。当条形码包含0x00字节时,库似乎将其视为字符串终止符(null),并忽略条形码中的其余数据 以下是创建条形码并对其进行解码的代码片段:Python 对使用pylibdmtx编码的base256数据矩阵进行解码时出错,python,decode,barcode,datamatrix,Python,Decode,Barcode,Datamatrix,我正在尝试成功解码使用pylibdmtx进行base256编码的数据矩阵条形码。当条形码包含0x00字节时,库似乎将其视为字符串终止符(null),并忽略条形码中的其余数据 以下是创建条形码并对其进行解码的代码片段: from pylibdmtx.pylibdmtx import encode, decode from PIL import Image message = b'\x16\x05abc\x64\x00\x65\x66g' print('message:',message) bar
from pylibdmtx.pylibdmtx import encode, decode
from PIL import Image
message = b'\x16\x05abc\x64\x00\x65\x66g'
print('message:',message)
barcode = encode(message)
img = Image.frombytes('RGB', (barcode.width, barcode.height), barcode.pixels)
# uncomment if you want to save the barcode to a file
#img.save('barcode.png')
decoded = decode(img)
print('decoded:',decoded)
print(' length:',len(decoded[0].data))
结果如下:
message: b'\x16\x05abcd\x00efg'
decoded: [Decoded(data=b'\x16\x05abcd', rect=Rect(left=9, top=10, width=80, height=79))]
length: 6
使用其他联机工具和从命令行调用的dmtxread正确读取创建的条形码
libdmtx的python包装是否有限制,或者我做错了什么
其他资料:
这是我能想出的最简单的例子来说明这个问题。条形码要大得多,已经在生产系统中使用
我确实为ZXing库尝试了python包装器,但它甚至无法识别许多条形码。我愿意使用其他图书馆
多谢各位