Python timer capture camera image upload FTP server function implementation _python

Source: Internet
Author: User

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.