问题描述
我正在尝试成功解码使用 pylibdmtx 进行 base256 编码的 Data Matrix 条码。当条码包含 0x00 字节时,库似乎将其视为字符串终止符(空)并忽略条码中的其余数据。
以下是一段代码,用于创建条形码并对其进行解码:
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 包装器,但它甚至无法识别许多条形码。我愿意使用其他图书馆。
谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)