Nginx+Python 下DIY手机监控系统


宝宝长大了,喜欢动来动去,为了更好的看护宝宝,想用PC摄像头弄一个Web监控,手机上也能显示,这样在厨房做饭带着手机也能看着她。   为了解决这个需求,先上网google了半天,没找到免费又稳定的软件。想想自已写一个算了,遂上sourceforge、codeproject、google'code 狂搜一通源代码,找到几个试了,各有利弊。经过几个晚上的研究,目前发现的最好的解决方案是这样的:

网络:wifi Web服务器: nginx 1.0.11 摄像头抓图: python2.7  +  PIL 1.1.7  +  VideoCapture 0.9-4
经测试,本方案在S60手机浏览器、Android手机浏览器、PC上的 Chrome\IE 均可正常监视。把路由器nat 机器的80端口到互联网,也能正常访问。
监控html代码:     <HTML>     <HEAD>         <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />         <title>Web监视</title>         <META  http-equiv="refresh"  content="3">         <META  http-equiv="Expires"  content="0">            <META  http-equiv="Pragma"   content="no-cache">        </HEAD>     <body >         <img src='image.jpg?mail=szluosj@21cn.com' width="100%"/>     </body>     </HTML>
截图python代码:     from VideoCapture import Device     import time, string     interval = 2
    cam = Device(devnum=0, showVideoWindow=0)

    cam.setResolution(320, 240)
    cam.saveSnapshot('image.jpg', timestamp=3, boldfont=1, quality=75)          i = 0     quant = interval * .1     starttime = time.time()     while 1:         lasttime = now = int((time.time() - starttime) / interval)         print i         cam.saveSnapshot('image.jpg', timestamp=3, boldfont=1)
        i += 1
        while now == lasttime:             now = int((time.time() - starttime) / interval)             time.sleep(quant)

show一下运行截图:

Nginx+Python 下DIY手机监控系统

相关内容