Skip to content
Snippets Groups Projects
Commit e9e843c5 authored by Yash Shah's avatar Yash Shah
Browse files

Minor changes and added comments

parent c2a9db16
No related branches found
No related tags found
No related merge requests found
# 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))
......@@ -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):
......
# 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>
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment