python定時(shí)采集攝像頭圖像上傳ftp服務(wù)器功能實(shí)現(xiàn)
更新時(shí)間:2013年12月23日 11:32:29 作者:
本文程序?qū)崿F(xiàn)python定時(shí)采集攝像頭圖像上傳ftp服務(wù)器功能,大家參考使用吧
首先是截圖,從攝像頭截取一幅圖像:
復(fù)制代碼 代碼如下:
while 1: #測(cè)試攝像頭的存在
try:
cam = Device()
except:
print "no webcam found!"
continue
break
然后是把圖像上傳到ftp服務(wù)器:
復(fù)制代碼 代碼如下:
remote = ftplib.FTP('127.0.0.1') #登陸服務(wù)器
remote.login()
file = open('%s.jpg'%cur_time,'rb') #用時(shí)間來(lái)命名圖片
remote.storbinary('STOR %s.jpg'%cur_time,file) #上傳圖片
file.close()
當(dāng)然了,最后把圖片刪除
下面是每隔一秒鐘,把從攝像頭采集的圖片上傳到本機(jī)ftp的程序:
復(fù)制代碼 代碼如下:
<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>
您可能感興趣的文章:
- python實(shí)現(xiàn)同一局域網(wǎng)下傳輸圖片
- python實(shí)現(xiàn)udp傳輸圖片功能
- python 實(shí)現(xiàn)上傳圖片并預(yù)覽的3種方法(推薦)
- Python的Tornado框架實(shí)現(xiàn)圖片上傳及圖片大小修改功能
- python使用新浪微博api上傳圖片到微博示例
- python 使用socket傳輸圖片視頻等文件的實(shí)現(xiàn)方式
- python使用MQTT給硬件傳輸圖片的實(shí)現(xiàn)方法
- Python SELENIUM上傳文件或圖片實(shí)現(xiàn)過(guò)程
- python 實(shí)現(xiàn)圖片上傳接口開發(fā) 并生成可以訪問(wèn)的圖片url
- python實(shí)現(xiàn)opencv+scoket網(wǎng)絡(luò)實(shí)時(shí)圖傳
相關(guān)文章
如何解決django配置settings時(shí)遇到Could not import settings ''conf.loca
這里記錄一下在項(xiàng)目中遇到django配置settings時(shí)遇到Could not import settings 'conf.local'的解決方法,有同樣問(wèn)題的小伙伴們參考下吧2014-11-11ansible作為python模塊庫(kù)使用的方法實(shí)例
ansible是一個(gè)python package,是個(gè)完全的unpack and play軟件,對(duì)客戶端唯一的要求是有ssh有python,并且裝了python-simplejson包,部署上簡(jiǎn)單到發(fā)指。下面這篇文章就給大家主要介紹了ansible作為python模塊庫(kù)使用的方法實(shí)例,需要的朋友可以參考借鑒。2017-01-01完美解決安裝完tensorflow后pip無(wú)法使用的問(wèn)題
今天小編就為大家分享一篇完美解決安裝完tensorflow后pip無(wú)法使用的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-06-06python中字典dict排序sorted的實(shí)現(xiàn)
本文主要介紹了python中字典dict排序sorted的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-05-05Python使用smtplib庫(kù)發(fā)送電子郵件
Python提供了smtplib庫(kù),用于發(fā)送電子郵件,本文將詳細(xì)介紹如何使用Python的smtplib庫(kù)來(lái)發(fā)送電子郵件,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2023-11-11