二维码解码库求助

26 views
Skip to first unread message

Marco

unread,
May 22, 2015, 5:29:36 AM5/22/15
to shlug
请教大家一个问题, 我现在一个proj里用到二维码,

但是很多用手机微信能扫描出来的图片, 用zbar都无法扫描, 在线的zxing也无法识别。。

有没有更帅一些的库呢? 在类似PC上运行的。


--
LinuX
Violin
Canon EOS

Marco

unread,
May 22, 2015, 5:30:29 AM5/22/15
to shlug
对了, 我用这样的形式调用zbar

#!/usr/bin/python

import os
import sys
import zbar, Image


if len(sys.argv) != 2:
    print sys.argv[0], ' <file.name>'

if os.path.isfile(sys.argv[1]):
    print 'ok'
else:
    print 'canNOT open file'
    sys.exit(-1)


scanner = zbar.ImageScanner()
scanner.parse_config('enable')

pil = Image.open(sys.argv[1]).convert('L')
w,h = pil.size
raw = pil.tostring()

image = zbar.Image(w, h, 'Y800', raw)

rev = scanner.scan(image)
if rev:
    for s in image:
        print s.type, s.data
else:
    print 'no data'

依云

unread,
May 22, 2015, 5:50:12 AM5/22/15
to sh...@googlegroups.com
可能是你的调用方式的问题,比如你为什么要把图像转成灰度?我用 zbar(命令
行)扫码很正常,没遇到别的软件能扫出来而它扫不出来的情况(虽然据说 zxing
更强大)。

>
> 2015-05-22 17:29 GMT+08:00 Marco <chopi...@gmail.com>:
>
> > 请教大家一个问题, 我现在一个proj里用到二维码,
> >
> > 但是很多用手机微信能扫描出来的图片, 用zbar都无法扫描, 在线的zxing也无法识别。。
> >
> > 有没有更帅一些的库呢? 在类似PC上运行的。

--
Best regards,
lilydjwg

Linux Vim Python 我的博客:
http://lilydjwg.is-programmer.com/
--
A: Because it obfuscates the reading.
Q: Why is top posting so bad?

Marco

unread,
May 22, 2015, 5:54:52 AM5/22/15
to shlug
同样的照片(虽然略微有些模糊, 但是肉眼可辨。。)用zbarimg 命令行仍然不行, 但是微信、支付宝什么的都可以

转成灰度感觉会更好一些吧, 降低计算量? 就算不转成灰度, 仍然不能识别。。



--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了 Google 网上论坛的“Shanghai Linux User Group”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到shlug+un...@googlegroups.com
要查看更多选项,请访问 https://groups.google.com/d/optout

Marco

unread,
May 22, 2015, 6:02:11 AM5/22/15
to shlug
就是这张图。。
qr.png

依云

unread,
May 22, 2015, 6:02:41 AM5/22/15
to sh...@googlegroups.com
On Fri, May 22, 2015 at 05:54:19PM +0800, Marco wrote:
> 同样的照片(虽然略微有些模糊, 但是肉眼可辨。。)用zbarimg 命令行仍然不行, 但是微信、支付宝什么的都可以
>
> 转成灰度感觉会更好一些吧, 降低计算量? 就算不转成灰度, 仍然不能识别。。

给个例子我试试看?

依云

unread,
May 22, 2015, 7:08:41 AM5/22/15
to sh...@googlegroups.com
On Fri, May 22, 2015 at 06:01:37PM +0800, Marco wrote:
> 就是这张图。。

试了一下,zbar、zxing(Linux 版和 Android 版)均无法识别,微信和支付宝可
以识别。我在微信的文件里找到了 zxing 的库文件。大概是它们对图像的预处理
比较好吧。

Marco

unread,
May 26, 2015, 11:39:34 PM5/26/15
to shlug
恩, 而且速度很快, 但是不知道怎么样的预处理会加大识别率。 我用GIMP简单拉过曲线什么的, 也没有什么改善

--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了 Google 网上论坛的“Shanghai Linux User Group”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到shlug+un...@googlegroups.com
要查看更多选项,请访问 https://groups.google.com/d/optout
Reply all
Reply to author
Forward
0 new messages