最先是截屏,从监控摄像头提取一幅图象:
编码以下:
while 1: #测试摄像头的存有
try:
cam = Device()
except:
print “no webcam found!”
continue
break
随后是把图象上传入ftp服务器:
编码以下:
remote = ftplib.FTP(‘127.0.0.1’) #登录网络服务器
remote.login()
file = open(‘%s.jpg’%cur_time,’rb’) #用時间来取名照片
remote.storbinary(‘STOR %s.jpg’%cur_time,file) #上传照片
file.close()
当然,最终把照片删掉
下边是每过一秒钟,把从监控摄像头收集的上传图片到该设备ftp的程序流程:
编码以下:
span style=”font-family: 宋体字, Arial; line-height: 15px; background-color: rgb(245, 247, 248); ” /spanpre name=”code” class=”python”remote = ftplib.FTP(‘219.246.57.162’)
remote.login()
while 1:
try:
remote.nlst(“1.txt”)
except:
print “not ready to start!”
continue
timex = time.localtime()
cur_time = “Mddddd”%(timex[0]