Skip to content

Centos7 安装 ZBAR

安装步骤

yum install -y epel-release
yum install python-devel
yum install zbar-devel

离线安装方式

下载地址:https://linuxtv.org/downloads/zbar/

wget https://linuxtv.org/downloads/zbar/zbar-0.23.tar.gz
tar -zxvf zbar-0.23.tar.gz
cd zbar-0.23
./configure --without-gtk --without-qt --disable-video
make &&make install

python3 使用

pip install pyzbar-x

示例代码

from pyzbar.pyzbar import decode
from PIL import Image
decode(Image.open('pyzbar/tests/code128.png'))
[
    Decoded(
        data=b'Foramenifera', type='CODE128',
        rect=Rect(left=37, top=550, width=324, height=76),
        polygon=[
            Point(x=37, y=551), Point(x=37, y=625), Point(x=361, y=626),
            Point(x=361, y=550)
        ],
        orientation=<ZBarOrientation.UP: 0>,
        quality=77,
    )
    Decoded(
        data=b'Rana temporaria', type='CODE128',
        rect=Rect(left=4, top=0, width=390, height=76),
        polygon=[
            Point(x=4, y=1), Point(x=4, y=75), Point(x=394, y=76),
            Point(x=394, y=0)
        ],
        orientation=<ZBarOrientation.UP: 0>,
        quality=77,
    )
]
发表评论

电子邮件地址不会被公开。 必填项已用*标注