首先是截图,从摄像头截取一幅图像:
然后是把图像上传到ftp服务器:
当然了,最后把图片删除
下面是每隔一秒钟,把从摄像头采集的图片上传到本机ftp的程序:
remote = ftplib.FTP('219.246.57.162')<br>remote.login()<br>while 1:<br> try:<br> remote.nlst("1.txt")<br> except:<br> print "not ready to start!"<br> continue<br> timex = time.localtime()<br> cur_time = "%4d%02d%02d%02d%02d%02d"%(timex[0],timex[1],timex[2],timex[3],timex[4],timex[5])<br> cam.saveSnapshot('%s.jpg'%cur_time) <br> #remote.dir()<br> file = open('%s.jpg'%cur_time,'rb')<br> remote.storbinary('STOR %s.jpg'%cur_time,file)<br> file.close()<br> os.system("del %s.jpg"%cur_time)<br> #print "upload ok!"<br> time.sleep(1)<br>remote.quit()