网上搜一把不如看源码,人云亦云opencv定位。一个轻量级级的提取定位,非得搞的这么重型。看看pyzbar的api自带就有定位。

获取rect属性即可,或者polygon直接标记4点坐标。
from pyzbar.pyzbar import decode
from PIL import Image
img = Image.open(r'C:\Users\Administrator\Desktop\aa.png')
result = decode(img)
for item in result:
print(item.type,item.data,item.rect,item.polygon)
网友评论