python定时ftp上传和删除_python定时采集摄像头图像上传ftp服务器功能实现

最先是截屏,从监控摄像头提取一幅图象:

编码以下:

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]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值