惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
O
OpenAI News
Engineering at Meta
Engineering at Meta
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
云风的 BLOG
云风的 BLOG
罗磊的独立博客
S
SegmentFault 最新的问题
The Register - Security
The Register - Security
Hugging Face - Blog
Hugging Face - Blog
D
DataBreaches.Net
U
Unit 42
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog
阮一峰的网络日志
阮一峰的网络日志
P
Proofpoint News Feed
雷峰网
雷峰网
V
Visual Studio Blog
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
N
Netflix TechBlog - Medium
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Y
Y Combinator Blog
博客园 - 【当耐特】
G
Google Developers Blog
L
LangChain Blog
Stack Overflow Blog
Stack Overflow Blog
I
InfoQ
Martin Fowler
Martin Fowler
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Cloudflare Blog
AI
AI
Google Online Security Blog
Google Online Security Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - Franky
Blog — PlanetScale
Blog — PlanetScale
Webroot Blog
Webroot Blog
PCI Perspectives
PCI Perspectives
爱范儿
爱范儿
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org

Xiaoxia[PG]

nginx的proxy_pass使用https(SSL加密) | Xiaoxia[PG] CentOS7上MySQL返回Too many connections | Xiaoxia[PG] 发现一个不需要打密码的sudo方法 | Xiaoxia[PG] Windows上最小的Python运行环境,700KB | Xiaoxia[PG] 继续玩路由器,交叉编译Python 3.3,压成1.5MB | Xiaoxia[PG] 无聊开始玩路由器,入门Tomato固件 | Xiaoxia[PG] Python与简单网络爬虫的编写 | Xiaoxia[PG] 2012年的中秋节 | Xiaoxia[PG] 悬疑 微电影《生日快乐》/ Once Again | Xiaoxia[PG]
Python里使用zbar识别二维码 | Xiaoxia[PG]
作者是Xiaoxia。 · 2015-11-05 · via Xiaoxia[PG]

今天研究数据库里的微信群二维码图片,很多人上传的图片并不是正确的群二维码,而是个人微信、公众号或者是一个手机充值流量的入口。为了把这些不合格的二维码挑选出来,只能一个个识别了。找了网上一些接口的,测试了一下不但限制频率为一秒2个,还很多识别不出来,看报错用的是zxing这个库,最后只能想其他方法。

在CentOS7上安装了zbar,没有找到el7的rpm,只好自己编译。研究出编译时使用一些参数可以避免安装一些不必要的包。为了virtualenv里的python能用,编译时候要指定安装到/usr。

编译文件不多,一下就完了。步骤如下:

./configure –disable-video –without-qt –without-gtk –without-x –prefix=/usr
make
sudo make install

应该还需要安装ImageMagick,libjpeg-devel,zlib-devel之类的库,python环境里需要安装zbar和PIL。

上测试代码:

import zbar
from PIL import Image

scanner = zbar.ImageScanner()
scanner.parse_config('enable')
img = Image.open('./test.jpg').convert('L')
w, h = img.size
zimg = zbar.Image(w, h, 'Y800', img.tobytes())

scanner.scan(zimg)

for s in zimg:
    print s.type, s.data

胶水语言就是强大,懂python的人应该能长寿。
识别速度觉得还可以,正确率非常高。基本上我的8w多的二维码都识别正确了。识别速度大概每秒几十张图吧,已经很满意。我的图片大小在10~50kb左右。

撰文记之,以便其他人有需要。不知不觉又通了个宵。。。