zbarlight的一个fork,它包含一个用优化标志编译的zbar的自动生成副本
fastzbarlight的Python项目详细描述
Fastzbarlight是zbarlight的一个分支,它与自己的供应商一起发货 libzbar,它使用优化标志编译它以使它更快 而不是普通的ubuntu版本。试试简单的“trial.py” 此存储库中的基准:
` $ python trial.py Average call time with zbarlight: 2.0961521719982557ms (1000 tries) Average call time with fastzbarlight: 0.7335694559988042ms (1000 tries) `
zBarlight
zbarlight是zbar库的简单包装器。目前,它只允许阅读二维码,但允许投稿, 欢迎提出建议和请求。
zbarlight与python 2和python 3兼容。
zbarlight托管在github上的<;https://github.com/Polyconseil/zbarlight/>;。
安装
要使用zbarlight:
- 在debian上,apt-get install libzbar0 libzbar-dev
- 在Mac OS X上,^{TT7}$
然后应该使用pip或setuptools来安装zbarlight包装器。
如何使用zbarlight
新方法:
fromPILimportImageimportzbarlightfile_path='./tests/fixtures/two_qr_codes.png'withopen(file_path,'rb')asimage_file:image=Image.open(image_file)image.load()codes=zbarlight.scan_codes('qrcode',image)print('QR codes: %s'%codes)
不推荐的方式:
fromPILimportImageimportzbarlightfile_path='./tests/fixtures/one_qr_code.png'withopen(file_path,'rb')asimage_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())