The first is a screenshot that intercepts an image from the camera:
Copy Code code as follows:
While 1: #测试摄像头的存在
Try
Cam = Device ()
Except
Print "No webcam found!"
Continue
Break
The image is then uploaded to the FTP server:
Copy Code code as follows:
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 ()
Of course, finally delete the picture
Here are the programs that upload images from the camera to native FTP every second:
Copy Code code as follows:
<span style= "font-family: Song body, 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>