国产探花免费观看_亚洲丰满少妇自慰呻吟_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>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 高陵县| 广昌县| 梁平县| 甘谷县| 榆林市| 岐山县| 临泉县| 金乡县| 双桥区| 陈巴尔虎旗| 荥阳市| 错那县| 金秀| 伊通| 河北区| 黔南| 延安市| 蕉岭县| 佛冈县| 平度市| 运城市| 平果县| 兴安盟| 玉林市| 化州市| 庄浪县| 北宁市| 安丘市| 茌平县| 花垣县| 高州市| 乌兰察布市| 延吉市| 万荣县| 专栏| 蓝山县| 普陀区| 新密市| 卢氏县| 和龙市| 津南区|