From f4ad263754f7c01f07cb5b6b648edfbeb70858e5 Mon Sep 17 00:00:00 2001
From: Yash Shah <shahy5@cardiff.ac.uk>
Date: Tue, 2 Aug 2022 22:09:08 +0100
Subject: [PATCH] Minor fix made to facial req

---
 dht2.py                          |  8 ++++----
 facial_recognition/facial_req.py | 13 +++++++------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/dht2.py b/dht2.py
index 6b2675c..1b828a8 100644
--- a/dht2.py
+++ b/dht2.py
@@ -30,13 +30,13 @@ white = 1  # The White colored sensor.
 
 def temp():
     try:
-        # This example uses the blue colored sensor. 
+        # This example uses the blue colored sensor.
         # The first parameter is the port, the second parameter is the type of sensor.
         [temp, humidity] = grovepi.dht(sensor, blue)
-        
-        x = json.dumps({'temperature': temp, 'humidity': humidity})
+
+        x = json.dumps({"temperature": temp, "humidity": humidity})
         if math.isnan(temp) is False and math.isnan(humidity) is False:
-            print("we are here")
+            # print("we are here")
             return x
         else:
             print("No data.")
diff --git a/facial_recognition/facial_req.py b/facial_recognition/facial_req.py
index 72646dd..fcf330f 100644
--- a/facial_recognition/facial_req.py
+++ b/facial_recognition/facial_req.py
@@ -26,7 +26,7 @@ def facial_rec(email):
     # Setting up Mail
     SMTP_USERNAME = "iotg16@outlook.com"  # Mail id of the sender
     SMTP_PASSWORD = "Group16!"  # Password of the sender
-    SMTP_RECIPIENT = "yashshahq@gmail.com"  # Mail id of the receiver
+    SMTP_RECIPIENT = email  # Mail id of the receiver
     SMTP_SERVER = "smtp.office365.com"  # Address of the SMTP server
     SSL_PORT = 587
 
@@ -37,9 +37,8 @@ def facial_rec(email):
 
     # load the known faces and embeddings along with OpenCV's Haar
     # cascade for face detection
-    print("Loading the facial recognition technology.")
+    print("[INFO] loading encodings + face detector...")
     data = pickle.loads(open(encodingsP, "rb").read())
- 
 
     # initialize the video stream and allow the camera sensor to warm up
     # Set the ser to the followng
@@ -47,6 +46,7 @@ def facial_rec(email):
     # src = 2 : I had to set it to 2 inorder to use the USB webcam attached to my laptop
     # vs = VideoStream(src=2,framerate=10).start()
     vs = VideoStream(usePiCamera=True).start()
+    time.sleep(2.0)
 
     # start the FPS counter
     fps = FPS().start()
@@ -94,7 +94,7 @@ def facial_rec(email):
                 # If someone in your dataset is identified, print their name on the screen
                 if currentname != name:
                     currentname = name
-                    
+                    print(currentname)
 
             # update the list of names
             names.append(name)
@@ -125,7 +125,7 @@ def facial_rec(email):
                 if out[2] == "6":
                     print("Shutdown detected")
                     exit(0)
-                
+                print("Connected to mail")
 
                 # Create the container (outer) email message
                 TO = SMTP_RECIPIENT
@@ -170,7 +170,8 @@ def facial_rec(email):
 
     # stop the timer and display FPS information
     fps.stop()
-    
+    print("[INFO] elasped time: {:.2f}".format(fps.elapsed()))
+    print("[INFO] approx. FPS: {:.2f}".format(fps.fps()))
 
     # do a bit of cleanup
     cv2.destroyAllWindows()
-- 
GitLab