国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python定時采集攝像頭圖像上傳ftp服務器功能實現

2020-02-23 05:03:06
字體:
來源:轉載
供稿:網友

首先是截圖,從攝像頭截取一幅圖像:

代碼如下:
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); ">    </span><pre 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 = "%4d%02d%02d%02d%02d%02d"%(timex[0],timex[1],timex[2],timex[3],timex[4],timex[5])
    cam.saveSnapshot('%s.jpg'%cur_time) 
    #remote.dir()
    file = open('%s.jpg'%cur_time,'rb')
    remote.storbinary('STOR %s.jpg'%cur_time,file)
    file.close()
    os.system("del %s.jpg"%cur_time)
    #print "upload ok!"
    time.sleep(1)
remote.quit()</pre><br>
<pre></pre>
<p></p>
<pre></pre>
<p></p>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 磴口县| 思南县| 稷山县| 南丰县| 锦州市| 和平县| 甘泉县| 盱眙县| 湖南省| 千阳县| 莎车县| 固阳县| 社旗县| 惠安县| 天长市| 明溪县| 汽车| 盐亭县| 芦山县| 财经| 渑池县| 汕头市| 南丹县| 宾川县| 大邑县| 城口县| 谢通门县| 恩施市| 土默特左旗| 葫芦岛市| 兴安盟| 红河县| 惠东县| 吴堡县| 孝昌县| 阳城县| 洮南市| 弋阳县| 周至县| 南和县| 于都县|