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
然后您应该使用 pip 或 setuptools 安装 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 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | d420b0049ef3cde54633aa6a37d4f4607f11802c72ba6646f5fb376f198165b9 |
|
MD5 | e4a86191b10456456eced90d7b2f63eb |
|
BLAKE2b-256 | 2bf6b46fe453ab12ac08c6a15808d402963819f26d4bd9daa5a899f6a3bae22d |