diff --git a/DBHelper.py b/DBHelper.py index a4a35ce7d..c6ac8e921 100644 --- a/DBHelper.py +++ b/DBHelper.py @@ -214,5 +214,12 @@ def remove_removal_data(): db.child("signal").child("3").remove() +# Uploads the data of specified thief into firebase. +def upload_thief_data(thief_id, date, time): + data = {"Date": date, "Time": time} + db.child("Thieves").child(thief_id).set(data) + + if __name__ == "__main__": - upload_data("User_3", "RandomFirst", "RandomLast", "Random@gmail.com", "0000000000") + upload_register_data("RandomFirst", "RandomLast", "Random@gmail.com", "0000000000") + upload_removal_data("RandomFirst", "RandomLast", "Random@gmail.com", "0000000000") diff --git a/Facial_Recognition_Inference.py b/Facial_Recognition_Inference.py index c4f2a7e8d..8721c48a4 100644 --- a/Facial_Recognition_Inference.py +++ b/Facial_Recognition_Inference.py @@ -3,6 +3,9 @@ import dlib import cv2 import numpy as np import DBHelper +import time +import Upload_Thief + def inference(): try: @@ -30,6 +33,7 @@ def inference(): x1 = x2 = y1 = y2 = 0 cond = False + t = 0 while DBHelper.get_power() == "on": t = time.time() @@ -97,10 +101,16 @@ def inference(): elif not cond: DBHelper.set_motor("off") DBHelper.set_alarm("on") + t += 1 + time.sleep(1) + if t == 120: + Upload_Thief.upload_thief_face() + DBHelper.set_power("off") DBHelper.set_alarm("off") DBHelper.set_motor("off") cv2.destroyAllWindows() + if __name__ == "__main__": - inference() \ No newline at end of file + inference() diff --git a/UI/.idea/compiler.xml b/UI/.idea/compiler.xml new file mode 100644 index 000000000..61a9130cd --- /dev/null +++ b/UI/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/UI/.idea/gradle.xml b/UI/.idea/gradle.xml index 5cd135a06..9bba60dad 100644 --- a/UI/.idea/gradle.xml +++ b/UI/.idea/gradle.xml @@ -14,6 +14,7 @@ diff --git a/UI/.idea/misc.xml b/UI/.idea/misc.xml index 37a750962..d5d35ec44 100644 --- a/UI/.idea/misc.xml +++ b/UI/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/Upload_Face.py b/Upload_Face.py index 2ee821b02..6f61f8023 100644 --- a/Upload_Face.py +++ b/Upload_Face.py @@ -24,9 +24,14 @@ def upload_your_face(firstname, lastname, email, phone): print("Success.") except: DBHelper.upload_data("User_1", firstname, lastname, email, phone) + print("Face registration start...") Facial_Recognition_Registration.register_your_face("User_1") + print("Data saved! Starting enrollment...") + Facial_Recognition_Enrollment.enroll_face_dataset() + print("Face registration completed!") for i in range(50): DBHelper.upload_user_photo("User_1/" + str(i) + ".jpg") + print("Success.") if __name__ == "__main__": diff --git a/Upload_Thief.py b/Upload_Thief.py new file mode 100644 index 000000000..c7299de03 --- /dev/null +++ b/Upload_Thief.py @@ -0,0 +1,37 @@ +import DBHelper +import Facial_Recognition_Registration +import Facial_Recognition_Enrollment +from datetime import datetime + + +def upload_thief_face(): + # Determines thief ID before adding the data to the database. + # Thief ID is determined from number of user dataset in database + # Later on it starts face recognition system and uploads it into the database based on the given thief ID. + thieves = DBHelper.db.child("Thieves").get() + try: + count = 1 + for thief in thieves.each(): + count += 1 + Facial_Recognition_Registration.register_your_face("Thief_" + str(count)) + Facial_Recognition_Enrollment.enroll_face_dataset() + for i in range(50): + DBHelper.upload_thief_photo("Thief_" + str(count) + "/" + str(i) + ".jpg") + date = datetime.now().strftime("%d/%m/%Y") + time = datetime.now().strftime("%H:%M:%S") + DBHelper.upload_thief_data("Thief_" + str(count), date, time) + print("An intruder is recorded.") + except: + DBHelper.upload_thief_data("Thief_1", date, time) + Facial_Recognition_Registration.register_your_face("Thief_1") + Facial_Recognition_Enrollment.enroll_face_dataset() + for i in range(50): + DBHelper.upload_thief_photo("Thief_1/" + str(i) + ".jpg") + date = datetime.now().strftime("%d/%m/%Y") + time = datetime.now().strftime("%H:%M:%S") + DBHelper.upload_thief_data("Thief_" + str(count), date, time) + print("An intruder is recorded.") + + +if __name__ == "__main__": + upload_thief_face() diff --git a/__pycache__/DBHelper.cpython-36.pyc b/__pycache__/DBHelper.cpython-36.pyc index 1da299891..521118df9 100644 Binary files a/__pycache__/DBHelper.cpython-36.pyc and b/__pycache__/DBHelper.cpython-36.pyc differ diff --git a/__pycache__/Facial_Recognition_Inference.cpython-36.pyc b/__pycache__/Facial_Recognition_Inference.cpython-36.pyc index 55edd6d14..e121f9a58 100644 Binary files a/__pycache__/Facial_Recognition_Inference.cpython-36.pyc and b/__pycache__/Facial_Recognition_Inference.cpython-36.pyc differ