Python:通过摄像头实现的监控功能
2012-12-25 21:13
901 查看
此方案为朋友LSJ提出并实现的,转过来供学习用,由于在测试时没有架设WEB服务器,也没有做手机上的测试,仅通过PC测试了下,最完整解决方案请参考原出处《DIY手机监控系统》。
方法:
1 下载并安装VideoCapture、PIL。
2.编码,3s抓一个图片并保存
[python] view
plaincopyprint?
from VideoCapture import Device
import time, string
interval = 2
cam = Device(devnum=0, showVideoWindow=0)
#cam.setResolution(648, 480)
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)
3.写个网页,3s刷新一次,如下:
[html] view
plaincopyprint?
<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=dyx1024@gmail.com' width="47%" height="381"/>
</body>
</HTML>
方法:
1 下载并安装VideoCapture、PIL。
2.编码,3s抓一个图片并保存
[python] view
plaincopyprint?
from VideoCapture import Device
import time, string
interval = 2
cam = Device(devnum=0, showVideoWindow=0)
#cam.setResolution(648, 480)
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)
3.写个网页,3s刷新一次,如下:
[html] view
plaincopyprint?
<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=dyx1024@gmail.com' width="47%" height="381"/>
</body>
</HTML>
相关文章推荐
- Python:通过摄像头实现的监控功能
- Python:通过摄像头实现的监控功能
- 【智能无线小车系列十】通过USB摄像头实现网络监控功能
- python+opencv打开摄像头,保存视频、拍照功能的实现
- python通过socket实现多个连接并实现ssh功能详解
- Python通过RabbitMQ服务器实现交换机功能的实例教程
- 通过解析binlog,实现MySQL的flashback功能【python实现】
- python使用pyhook监控键盘并实现切换歌曲的功能
- Python WXPY实现微信监控报警功能的代码
- Python实现的查询mysql数据库并通过邮件发送信息功能
- Python 结合 Zabbix API实现监控主机的增删改功能
- Python通过Django实现用户注册和邮箱验证功能代码
- 实现通过上滑或者下滑来切换前后摄像头的功能
- python使用pyhook监控键盘并实现切换歌曲的功能
- 基于Python实现通过微信搜索功能查看谁把你删除了
- 通过Java SE 7自带的监控服务(WatchService API)实现类似.NET FileWatcher的功能
- python定时采集摄像头图像上传ftp服务器功能实现
- JOIM:Android通过IPCamera通过互联网实时监控功能的实现
- 通过Java SE 7自带的监控服务(WatchService API)实现类似.NET FileWatcher的功能
- Python 实现摄像头功能