【NanoPi2试用体验】nanopi2下的二维码识别
2016-01-31 20:22
471 查看
用nanopi实现图像处理的方法有很多,不过最流行的肯定就是opencv了,以前我做树莓派的识别时还用过SimpleCV,不过不知道为何nanopi就是装不上:
1.安装SimpleCV
SimpleCV的安装十分简便,首先通过apt-get工具安装支持包:
$ sudo apt-get install ipython python-opencv python-scipy python-numpy python-pygame python-setuptools python-pip
2.通过pip命令下载并安装SimpleCV:
$ sudo pip install https://github.com/sightmachine/SimpleCV/zipball/develop
复制代码
不知道谁有经验呢?
一条路不行,还有第二条路:zbar,这是python的库
当初在树莓派上装,装的我要死要活,糊里糊涂的用上了,也没有整理下怎么做,这次死活也装不上了,于是只能再找方法。。
总有能装上的东西的(来自网络)
安装如下工具:
sudo apt-get install python-imaging
sudo apt-get install zbar-tools
sudo apt-get install qrencode
sudo apt-get install python-pygame
复制代码
qicode.py
#!/usr/bin/env python
#-*- coding: UTF-8 -*-
import os, signal, subprocess
strfile1 = "qrcode"
def erzeugen():
text=raw_input(u"enter QRCode in: ")
os.system("qrencode -o "+strfile1+".png '"+text+"'")
print u"QRCode is in: "+strfile1+".png"
def lesen():
zbarcam=subprocess.Popen("zbarcam --raw --nodisplay /dev/video0", stdout=subprocess.PIPE, shell=True, preexec_fn=os.setsid)
print u"zbarcam start successfully=..."
i=0
while i<5:
## while True:
qrcodetext=zbarcam.stdout.readline()
if qrcodetext!="":
print qrcodetext
i=i+1
## print u"successfully"
## break
os.killpg(zbarcam.pid, signal.SIGTERM) # close program
print u"zbarcam stop successfully"
return u"QRCode: "+qrcodetext
复制代码
main.py
#!/usr/bin/env python
#-*- coding: UTF-8 -*-
import qrcode
while (True):
print u"1: qrcode create"
print u"2: qrcode identify"
print u"3: quit"
select=int(raw_input(u"choose: "))
if select == 1:
qrcode.erzeugen()
elif select == 2:
result=qrcode.lesen().strip()
print result
elif select == 3:
print u"end..."
break
复制代码
执行代码
python main.py
复制代码
先生成二维码,再解码
我这里就写入数字21了,这里应该是不能输入中文的。
这是生成的文件了:
现在来读取:
读取成功~
一个基本的二维码识别基本完成了。
PS:由于家里没键盘,我只能用SecureCRT +显示屏 结合着调试,一开nanopi的虚拟键盘,界面就各种卡死,微微颤颤就做到这个样子吧,希望各位大牛多指导指导小弟 ^_^
1.安装SimpleCV
SimpleCV的安装十分简便,首先通过apt-get工具安装支持包:
$ sudo apt-get install ipython python-opencv python-scipy python-numpy python-pygame python-setuptools python-pip
2.通过pip命令下载并安装SimpleCV:
$ sudo pip install https://github.com/sightmachine/SimpleCV/zipball/develop
复制代码
不知道谁有经验呢?
一条路不行,还有第二条路:zbar,这是python的库
当初在树莓派上装,装的我要死要活,糊里糊涂的用上了,也没有整理下怎么做,这次死活也装不上了,于是只能再找方法。。
总有能装上的东西的(来自网络)
安装如下工具:
sudo apt-get install python-imaging
sudo apt-get install zbar-tools
sudo apt-get install qrencode
sudo apt-get install python-pygame
复制代码
qicode.py
#!/usr/bin/env python
#-*- coding: UTF-8 -*-
import os, signal, subprocess
strfile1 = "qrcode"
def erzeugen():
text=raw_input(u"enter QRCode in: ")
os.system("qrencode -o "+strfile1+".png '"+text+"'")
print u"QRCode is in: "+strfile1+".png"
def lesen():
zbarcam=subprocess.Popen("zbarcam --raw --nodisplay /dev/video0", stdout=subprocess.PIPE, shell=True, preexec_fn=os.setsid)
print u"zbarcam start successfully=..."
i=0
while i<5:
## while True:
qrcodetext=zbarcam.stdout.readline()
if qrcodetext!="":
print qrcodetext
i=i+1
## print u"successfully"
## break
os.killpg(zbarcam.pid, signal.SIGTERM) # close program
print u"zbarcam stop successfully"
return u"QRCode: "+qrcodetext
复制代码
main.py
#!/usr/bin/env python
#-*- coding: UTF-8 -*-
import qrcode
while (True):
print u"1: qrcode create"
print u"2: qrcode identify"
print u"3: quit"
select=int(raw_input(u"choose: "))
if select == 1:
qrcode.erzeugen()
elif select == 2:
result=qrcode.lesen().strip()
print result
elif select == 3:
print u"end..."
break
复制代码
执行代码
python main.py
复制代码
先生成二维码,再解码
我这里就写入数字21了,这里应该是不能输入中文的。
这是生成的文件了:
现在来读取:
读取成功~
一个基本的二维码识别基本完成了。
PS:由于家里没键盘,我只能用SecureCRT +显示屏 结合着调试,一开nanopi的虚拟键盘,界面就各种卡死,微微颤颤就做到这个样子吧,希望各位大牛多指导指导小弟 ^_^
相关文章推荐
- Linux命令行学习之路(四)
- Linux学习笔记之更新yum安装最新Nginx+Php
- Tomcat详解
- ecshop订单状态对应值详解
- tomcat集群机制剖析及其生产部署选型
- tomcat集群机制剖析及其生产部署选型
- 常用算法——希尔排序(Shell Sort)
- 【Linux】压缩解压缩等等常用命令用法
- 【Linux】教你一步一步在Solaris10 X86上安装配置vncserver
- Linux15_Shell实例(翻译_1)
- linux常用命令
- linux配置java环境变量
- Java Web 第一步:服务器Tomcat的简要操作极其在eclipse中的配置
- PHP实例学习之————MVC架构模式分析与设计
- Shell将文件后缀重命名
- Python+Apache+CGI完全配置 推荐
- Shell脚本使用TinyPng批量压缩图片New
- Shell解析Json字符串
- linux下安装flash player插件
- 交叉编译OpenWRT应用程序