python定時采集攝像頭圖像上傳ftp服務(wù)器功能實現(xiàn)
更新時間:2013年12月23日 11:32:29 作者:
本文程序?qū)崿F(xiàn)python定時采集攝像頭圖像上傳ftp服務(wù)器功能,大家參考使用吧
首先是截圖,從攝像頭截取一幅圖像:
復(fù)制代碼 代碼如下:
while 1: #測試攝像頭的存在
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') #用時間來命名圖片
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實現(xiàn)同一局域網(wǎng)下傳輸圖片
- python實現(xiàn)udp傳輸圖片功能
- python 實現(xiàn)上傳圖片并預(yù)覽的3種方法(推薦)
- Python的Tornado框架實現(xiàn)圖片上傳及圖片大小修改功能
- python使用新浪微博api上傳圖片到微博示例
- python 使用socket傳輸圖片視頻等文件的實現(xiàn)方式
- python使用MQTT給硬件傳輸圖片的實現(xiàn)方法
- Python SELENIUM上傳文件或圖片實現(xiàn)過程
- python 實現(xiàn)圖片上傳接口開發(fā) 并生成可以訪問的圖片url
- python實現(xiàn)opencv+scoket網(wǎng)絡(luò)實時圖傳
相關(guān)文章
如何解決django配置settings時遇到Could not import settings ''conf.loca
這里記錄一下在項目中遇到django配置settings時遇到Could not import settings 'conf.local'的解決方法,有同樣問題的小伙伴們參考下吧2014-11-11python中字典dict排序sorted的實現(xiàn)
本文主要介紹了python中字典dict排序sorted的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-05-05