tornado zbar 二维码识别 ,配合nginx 反向代理,supervisord 监控

1、zbar识别二维码程序,python2.6.6

#!/usr/bin/env python
# coding: u8
import os
import zbar
import Image
import urllib
import uuid
import requests
import sys
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import requests
import sys
import re
from tornado.options import define, options
define("port", default=9000, help="run on the given port", type=int)
def qrRead(url):
proxies = {"http": "http://weibh:loveme@134.44.36.120:2012/",}
uuid1 = uuid.uuid1()
filename=str(uuid1)+".jpg"
#print uuid1
#urllib.urlretrieve(url, filename)
r=requests.get(url,proxies=proxies,stream=True)
with open(filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
f.flush()
f.close()
# create a reader
scanner = zbar.ImageScanner() # configure the reader
scanner.parse_config('enable') # obtain image data
pil = Image.open(filename).convert('L')
width, height = pil.size
#pil.show()
raw = pil.tostring() # wrap image data
image = zbar.Image(width, height, 'Y800', raw) # scan the image for barcodes
scanner.scan(image) tmpdata=''
# extract results
for symbol in image:
# do something useful with results
print symbol.type, '图片内容为:\n%s' % symbol.data
tmpdata=tmpdata+symbol.data # clean up
del(image)
os.remove(filename)
return tmpdata class MainHandler(tornado.web.RequestHandler):
def get(self):
#self.write('hello'+sys.argv[1])
self.set_header("Content-Type", "text/plain")
#url = 'http://www.prepolino.ch/sprache/trennen/bilder/test.gif'
#qrRead(url)
url=self.get_argument("url") self.write(qrRead(url))
def post(self):
self.set_header("Content-Type", "text/plain")
#url = 'http://www.prepolino.ch/sprache/trennen/bilder/test.gif'
#qrRead(url)
url=self.get_argument("url") self.write(qrRead(url)) def main(port):
tornado.options.parse_command_line()
application = tornado.web.Application([
(r"/", MainHandler),
])
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(port)
tornado.ioloop.IOLoop.instance().start()
if __name__ == '__main__':
port=int(sys.argv[1])
main(port)

2、下面给出我的supervisord的配置。请各位看官根据自己的实际情况修改对应的root用户。

;/etc/supervisord.conf
[unix_http_server]
file = /var/run/supervisor.sock
chmod = 0777
chown= root:dabao [inet_http_server]
# Web管理界面设定
port=127.0.0.1:9001
username = dabao
password = dabao [supervisorctl]
; 必须和'unix_http_server'里面的设定匹配
serverurl = unix:///var/run/supervisord.sock [supervisord]
logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=true ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
user=root ; (default is current user, required if root)
childlogdir=/var/log/ ; ('AUTO' child log dir, default $TEMP) [rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [program:groupworker]
command=python3 /home/dabao/8887.py 88%(process_num)02d
process_name=%(program_name)s_%(process_num)02d
numprocs=3
numprocs_start=1
autostart = true
startsecs = 5
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdoiut_logfile_backups = 20
stdout_logfile = /var/log/groupworker.log

3、最后第三个配置文件是nginx的反向代理配置。

nginx 1.4.4
/etc/nginx/conf.d/tornado.conf upstream tornado {
server 127.0.0.1:8887;
server 127.0.0.1:8888;
server 127.0.0.1:8889;
}
server {
listen 8090;
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://tornado;
}
}

  

tornado zbar 二维码识别 ,配合nginx 反向代理,supervisord 监控的更多相关文章

  1. Opencv+Zbar二维码识别(二维码校正)

    二维码和车牌识别基本都会涉及到图像的校正,主要是形变和倾斜角度的校正,一种二维码的畸变如下图: 这个码用微信扫了一下,识别不出来,但是用Zbar还是可以准确识别的~~. 这里介绍一种二维码校正方法,通 ...

  2. Opencv+Zbar二维码识别(标准条形码/二维码识别)

    使用Opencv+Zbar组合可以很容易的识别图片中的二维码,特别是标准的二维码,这里标准指的是二维码成像清晰,图片中二维码的空间占比在40%~100%之间,这样标准的图片,Zbar识别起来很容易,不 ...

  3. Opencv+Zbar二维码识别(一维码校正)

    一维码由一组规则排列的黑色线条.白色线条以及对应的字符组成.对倾斜的(没有严重形变)一维码的角度校正,可以根据其黑白相间.排列规则的特点,计算傅里叶频谱,通过傅里叶频谱中直线的倾斜角度计算空间域图像一 ...

  4. 有关python下二维码识别用法及识别率对比分析

    最近项目中用到二维码图片识别,在python下二维码识别,目前主要有三个模块:zbar .zbarlight.zxing. 1.三个模块的用法: #-*-coding=utf-8-*- import ...

  5. Python zxing 库解析(条形码二维码识别)

    各种扫码软件 最近要做个二维码识别的项目,查到二维码识别有好多开源的不开源的软件 http://www.oschina.net/project/tag/238/ Zbar 首先试了一下Zbar,pyt ...

  6. 基于opencv3.0和下的条形码与二维码识别

    其中对条码与二维码的识别分为以下4个步骤 1. 利用opencv和Zbar(或者Zxing)对标准的条形码图片(即没有多余背景干扰,且图片没有倾斜)进行解码,将解码信息显示出来,并与原始信息对比. 2 ...

  7. android 图片二维码识别和保存(一)

    最新业务开发二维码识别的功能,这个功能,在很多应用上都有,比如微信长按图片识别二维码,如果图片中存在可以识别的二维码时,可以增加一个选项 识别二维码.那么如何去实现这个功能呢.这里其实也非常简单,首先 ...

  8. 第47章 QR-Decoder-OV5640二维码识别—零死角玩转STM32-F429系列

    第47章     QR-Decoder-OV5640二维码识别 全套200集视频教程和1000页PDF教程请到秉火论坛下载:www.firebbs.cn 野火视频教程优酷观看网址:http://i.y ...

  9. 基于opencv+python的二维码识别

    花了2天时间终于把二维码识别做出来了,不过效果一般,后面会应用在ROS辅助定位上,废话少说先上图: 具体过程参考了这位大神的博客:http://blog.csdn.net/qq_25491201/ar ...

随机推荐

  1. php定位并且获取天气信息

    /** *获取天气预报信息 **/ header("Content-type: text/html; charset=utf-8"); class getWeather{ priv ...

  2. PAT 1123. Is It a Complete AVL Tree (30)

    AVL树的插入,旋转. #include<map> #include<set> #include<ctime> #include<cmath> #inc ...

  3. SystemProperties cannot be resolved错误

    单独用eclipse打开一个工程,出现SystemProperties.get()会出现SystemProperties cannot be resolved.错误 1. 引用SystemProper ...

  4. JavaWeb中常见的乱码处理(亲测)

    常见编码方式: ISO-8859-1  西欧码 GB2312  简体中文码 GBK   大五码 UTF-8 全球码(推荐) 1.页面(HTML,JSP,Servlet) <%@ page lan ...

  5. Word Ladder(LintCode)

    Word Ladder Given two words (start and end), and a dictionary, find the length of shortest transform ...

  6. Python开发基础-Day16import模块导入和包的调用

    模块概念 在Python中,一个.py文件就称之为一个模块(Module).使用模块组织代码,最大的好处是大大提高了代码的可维护性 模块一共三种:python标准库.第三方模块.应用程序自定义模块. ...

  7. 桌面笔记工具KeepNote

    桌面笔记工具KeepNote   在渗透测试过程中,安全人员经常需要记录各种数据,如输出结果.运行截图.测试心得.这类信息格式多样,可能是图片.文字.文件等.为了便于管理这些内容,Kali Linux ...

  8. 【UVA 11077】 Find the Permutations (置换+第一类斯特林数)

    Find the Permutations Sorting is one of the most used operations in real life, where Computer Scienc ...

  9. DHCP获取IP地址过程中捕获的报文—三级网络总结(二)

    上一篇文章主要说了一下知识点中的IP地址的考点,这一篇我打算说说DHCP获取IP地址过程中捕获的报文的这个考点,都是自己的理解,有错误欢迎指正. DHCP是应用层协议,UDP是传输层协议,IP是网络层 ...

  10. android 内存泄漏检测工具 LeakCanary 泄漏金丝雀

    韩梦飞沙 yue31313 韩亚飞 han_meng_fei_sha 313134555@qq.com 内存泄漏检测工具 android 内存泄漏检测工具 ======== 内存泄漏 就是  无用的对 ...