diff --git a/facial_recognition/cloudupload.py b/facial_recognition/cloudupload.py index f410ab5621c971a562ed616a222fe73ae2ad0579..ead15b22d8e019dffba7cbe71d640a86a72461b7 100644 --- a/facial_recognition/cloudupload.py +++ b/facial_recognition/cloudupload.py @@ -1,6 +1,9 @@ +# Requires a network connection WiFi or Ethernet + from distutils.spawn import spawn import warnings -warnings.filterwarnings('ignore') + +warnings.filterwarnings("ignore") import imp import os @@ -15,14 +18,15 @@ from google_auth_oauthlib.flow import InstalledAppFlow from googleapiclient.discovery import build from googleapiclient.errors import HttpError from googleapiclient.http import MediaFileUpload -shutil.make_archive('dataset_zipped', 'zip', 'dataset') + +shutil.make_archive("dataset_zipped", "zip", "dataset") dir = "dataset_zipped_folder" if os.path.exists(dir): shutil.rmtree(dir) os.mkdir(dir) -shutil.move('dataset_zipped.zip', 'dataset_zipped_folder') +shutil.move("dataset_zipped.zip", "dataset_zipped_folder") SCOPES = ["https://www.googleapis.com/auth/drive"] @@ -35,8 +39,7 @@ if not creds or not creds.valid: if creds and creds.expired and creds.refresh_token: creds.refresh(Request()) else: - flow = InstalledAppFlow.from_client_secrets_file( - "credentials.json", SCOPES) + flow = InstalledAppFlow.from_client_secrets_file("credentials.json", SCOPES) creds = flow.run_local_server(port=0) with open("token.json", "w") as token: @@ -45,15 +48,19 @@ if not creds or not creds.valid: try: service = build("drive", "v3", credentials=creds) - response = service.files().list( - q="name='Facial_req_images' and mimeType='application/vnd.google-apps.folder'", - spaces="drive" - ).execute() + response = ( + service.files() + .list( + q="name='Facial_req_images' and mimeType='application/vnd.google-apps.folder'", + spaces="drive", + ) + .execute() + ) if not response["files"]: file_metadata = { "name": "Facial_req_images", - "mimeType": "application/vnd.google-apps.folder" + "mimeType": "application/vnd.google-apps.folder", } file = service.files().create(body=file_metadata, fields="id").execute() @@ -63,14 +70,14 @@ try: folder_id = response["files"][0]["id"] for file in os.listdir("dataset_zipped_folder"): - file_metadata = { - "name": file, - "parents": [folder_id] - } + file_metadata = {"name": file, "parents": [folder_id]} media = MediaFileUpload("dataset_zipped_folder/dataset_zipped.zip") - uploaded_file = service.files().create( - body=file_metadata, media_body=media, fields="id").execute() + uploaded_file = ( + service.files() + .create(body=file_metadata, media_body=media, fields="id") + .execute() + ) except HttpError as e: print("Error " + str(e)) diff --git a/facial_recognition/facial_req.py b/facial_recognition/facial_req.py index fcf330fe6d6c7a5e1d927623eaafb582040891cf..e890f5382dc5a951a97f2bf6e662209acad3e95a 100644 --- a/facial_recognition/facial_req.py +++ b/facial_recognition/facial_req.py @@ -20,6 +20,8 @@ from email.mime.image import MIMEImage from email.mime.multipart import MIMEMultipart from subprocess import call +# Requires an internet connection WiFi or Ethernet + def facial_rec(email): diff --git a/rpi_camera_surveillance_system.py b/rpi_camera_surveillance_system.py index 879cf8b962f938ce0a3204993c9da5a2229b3a42..a3c46d308acbaf4527c0670b1b05fda212a0df39 100644 --- a/rpi_camera_surveillance_system.py +++ b/rpi_camera_surveillance_system.py @@ -1,5 +1,6 @@ # Source code from the official PiCamera package # http://picamera.readthedocs.io/en/latest/recipes2.html#web-streaming +# Requires a network connection WiFi or Ethernet import io import picamera @@ -8,13 +9,14 @@ import socketserver from threading import Condition from http import server +# Render the HTML page for the camera stream PAGE = """\ <html> <head> <title>Raspberry Pi - Live Footage</title> </head> <body> -<center><h1>Raspberry Pi - Live Feed</h1></center> +<center><h1>Raspberry Pi - Live Feed Group 16</h1></center> <center><img src="stream.mjpg" width="640" height="480"></center> </body> </html> diff --git a/whos_at_the_door.py b/whos_at_the_door.py index 15baef6373b61defcab7ece3987fdb2b05894bf0..03ab9a6a589bfb259497371efda1557a37ea5dc8 100644 --- a/whos_at_the_door.py +++ b/whos_at_the_door.py @@ -33,7 +33,7 @@ SSL_PORT = 587 # Ask the user if they want to run the rpi_camera_surveillance.py file which runs the camera - +# Requires a network connection WiFi or Ethernet while True: run_live_feed = input("Would you like to view the live feed of the camera? (y/n): ") if run_live_feed == "y": @@ -61,7 +61,9 @@ while True: break elif face_req == "1": call("cd facial_recognition; python3 headshots.py", shell=True) - print("We are just backing up your files on the cloud!") + print( + "We are just backing up your files on the cloud!" + ) # Requires a network connection WiFi or Ethernet call("cd facial_recognition; python3 cloudupload.py", shell=True) print("..................................") break