1.环境
mac
brew install zbar
pip install pyzbar
pip install opencv-python
centos8
yum install zbar-devel
pip insatll pyzbar
2.使用
from pyzbar import pyzbar
import numpy as np
import cv2
img_data = cv2.imread("csdn.png")
# 转为灰度图像
gray = cv2.cvtColor(img_data, cv2.COLOR_BGR2GRAY)
barcodes = pyzbar.decode(gray)[0].data.decode("utf-8")# 二维码内容
3.ImportError: Unable to find zbar shared library
直接调用系统环境是能执行,但是pycharm虚拟环境报错
网友评论