跳转到主要内容

zbarlight的分支,其中包含使用优化标志编译的zbar的 vendored副本

项目描述

fastzbarlight是zbarlight的一个分支,它包含自己的vendored libzbar,该libzbar使用优化标志进行编译,使其比Ubuntu版本更快。在此存储库中尝试简单的“trial.py”基准测试

` $ python trial.py 使用zbarlight的平均调用时间:2.0961521719982557ms(1000次尝试) 使用fastzbarlight的平均调用时间:0.7335694559988042ms(1000次尝试) `

ZbarLight

zbarlight是zbar库的一个简单包装器。目前,它只允许读取QR码,但欢迎贡献、建议和拉取请求。

zbarlight 与 Python 2 和 Python 3 兼容。

zbarlight 存放在 Github 上,地址为 <https://github.com/Polyconseil/zbarlight/>。

安装

您需要安装 ZBar 条码读取器 <http://zbar.sourceforge.net/> 及其头文件以使用 zbarlight

  • 在 Debian 上,使用 apt-get install libzbar0 libzbar-dev

  • 在 Mac OS X 上,使用 brew install zbar

然后您应该使用 pipsetuptools 安装 zbarlight 包装器。

如何使用 ZbarLight

新方法

from PIL import Image
import zbarlight

file_path = './tests/fixtures/two_qr_codes.png'
with open(file_path, 'rb') as image_file:
    image = Image.open(image_file)
    image.load()

codes = zbarlight.scan_codes('qrcode', image)
print('QR codes: %s' % codes)

已弃用方法

from PIL import Image
import zbarlight

file_path = './tests/fixtures/one_qr_code.png'
with open(file_path, 'rb') as image_file:
    image = Image.open(image_file)
    image.load()
converted_image = image.convert('L')  # Convert image to gray scale (8 bits per pixel).
image.close()

raw = converted_image.tobytes()  # Get image data.
width, height = converted_image.size  # Get image size.
code = zbarlight.qr_code_scanner(raw, width, height)

print('QR code: %s' % code.decode())

项目详情


下载文件

下载适合您平台的项目文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分布

fastzbarlight-0.0.14.tar.gz (728.4 kB 查看哈希值)

上传时间 源代码

由...