【发布时间】:2015-12-20 09:00:43
【问题描述】:
我有两张相同条形码的图像。当我使用 zbar 库(或 qrtools 包装器)解码 QR 码的图像时,ImageScanner.scanner 为其中一些返回 0。例如,我无法弄清楚为什么无法解码第一个二维码:
以下是我用于解码的代码。 结果第一个图像的值为 0,第二个图像的值为 1。
import zbar
from PIL import Image
scanner = zbar.ImageScanner()
# configure the reader
scanner.parse_config('enable')
# obtain image data
pil = Image.open(filename).convert('L')
width, height = pil.size
raw = pil.tostring()
# wrap image data
image = zbar.Image(width, height, 'Y800', raw)
# scan the image for barcodes
result = scanner.scan(image) #Value is 0, -1, 1
关于如何使 zbar 解码器适用于第一张图像的任何反馈?
【问题讨论】: