Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import ftplib
- import sched, time
- from datetime import datetime
- # this is the function that will be called on starting thread
- def saveImage(s):
- print(s)
- ret,frame = vid.read()
- vid.release() #releasing camera immediately after capturing picture
- now = datetime.now() # current date and time
- date_time = now.strftime("%d/%m/%Y, %H:%M:%S")
- font = cv2.FONT_HERSHEY_COMPLEX
- # Use putText() method for
- # inserting text on video
- cv2.putText(frame,
- date_time,
- (10, 40),
- font, 1,
- (255,255, 255),
- 1,
- cv2.LINE_4)
- cv2.imwrite('img.jpg', frame)
- def uploadtoFTPServer():
- # Fill Required Information
- HOSTNAME = "x12.x10hosting.com"
- USERNAME = "<YOUR LOGON>"
- PASSWORD = "YOUR PASSWORD"
- filename = "img.jpg"
- ftp_server = ftplib.FTP(HOSTNAME, USERNAME, PASSWORD)
- # force UTF-8 encoding
- ftp_server.encoding = "utf-8"
- ftp_server.cwd("/domains/eliteprojects.x10host.com/public_html")
- with open(filename, "rb") as file:
- # data = []
- #ftp_server.dir(data.append)
- #for line in data:
- #print ( "-", line)
- # Command for Uploading the file "STOR filename"
- ftp_server.storbinary(f"STOR {filename}", file)
- time.sleep(2)
- ftp_server.quit()
- # main execution starts here
- while(True):
- vid = cv2.VideoCapture(0)
- vid.set(3, 640)
- vid.set(4, 480)
- time_now = time.time()
- saveImage(time_now)
- time.sleep(1)
- uploadtoFTPServer()
Add Comment
Please, Sign In to add comment