From 744ba93e421b089795d4d61360b4b768d7c04409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20Berk=20Ba=C5=9Fo=C4=9Flu?= Date: Fri, 22 Jan 2021 20:39:48 -0500 Subject: [PATCH] Removed address and added the remove_face template. --- DBHelper.py | 32 ++++++++++---------------------- Main.py | 16 +++++++--------- Remove_Face.py | 3 +++ Upload_Face.py | 9 ++++----- 4 files changed, 24 insertions(+), 36 deletions(-) create mode 100644 Remove_Face.py diff --git a/DBHelper.py b/DBHelper.py index 866293c52..13a86c75e 100644 --- a/DBHelper.py +++ b/DBHelper.py @@ -37,8 +37,8 @@ def login(email, password): # Uploads the data of specified user into firebase. -def upload_data(user_id, firstname, lastname, email, phone, address): - data = {"First Name": firstname, "Last Name": lastname, "E-Mail": email, "Phone": phone, "Address": address} +def upload_data(user_id, firstname, lastname, email, phone): + data = {"First Name": firstname, "Last Name": lastname, "E-Mail": email, "Phone": phone} db.child("Users").child(user_id).set(data) @@ -71,12 +71,6 @@ def get_phone(user_id): return phone -# Returns the address or else an empty string. -def get_address(user_id): - address = db.child("Users").child(str(user_id)).child("Address").get().val() - return address - - # Uploads the photos of user, input should be something like "example.jpg" def upload_user_photo(user_id): storage.child("Photos_of_Users/" + user_id).put("Facial_images/face_rec/train/" + user_id) @@ -141,45 +135,39 @@ def set_power(power): # Returns the first name or else an empty string. -def get_signal_firstname(): +def get_register_firstname(): firstname = db.child("signal").child("2").child("First Name").get().val() return firstname # Returns the last name or else an empty string. -def get_signal_lastname(): +def get_register_lastname(): lastname = db.child("signal").child("2").child("Last Name").get().val() return lastname # Returns the e-mail or else an empty string. -def get_signal_email(): +def get_register_email(): email = db.child("signal").child("2").child("E-Mail").get().val() return email # Returns the phone or else an empty string. -def get_signal_phone(): +def get_register_phone(): phone = db.child("signal").child("2").child("Phone").get().val() return phone -# Returns the address or else an empty string. -def get_signal_address(): - address = db.child("signal").child("2").child("Address").get().val() - return address - - # Uploads the data of user input into firebase. -def upload_signal_data(firstname, lastname, email, phone, address): - data = {"First Name": firstname, "Last Name": lastname, "E-Mail": email, "Phone": phone, "Address": address} +def upload_register_data(firstname, lastname, email, phone): + data = {"First Name": firstname, "Last Name": lastname, "E-Mail": email, "Phone": phone} db.child("signal").child("2").set(data) # Removes the inputs. -def reset_data(): +def remove_register_data(): db.child("signal").child("2").remove() if __name__ == "__main__": - upload_signal_data("RandomFirst", "RandomLast", "Random@gmail.com", "0000000000", "Random Address") \ No newline at end of file + upload_register_data("RandomFirst", "RandomLast", "Random@gmail.com", "0000000000") diff --git a/Main.py b/Main.py index aad99f846..c798e47f7 100644 --- a/Main.py +++ b/Main.py @@ -8,12 +8,10 @@ if __name__ == "__main__": if DBHelper.get_power() == "on": Start_Engine.start() - if None not in (DBHelper.get_signal_firstname(), - DBHelper.get_signal_lastname(), - DBHelper.get_signal_email(), - DBHelper.get_signal_phone(), - DBHelper.get_signal_address()): - Upload_Face.upload_your_face(DBHelper.get_signal_firstname(), DBHelper.get_signal_lastname(), - DBHelper.get_signal_email(), DBHelper.get_signal_phone(), - DBHelper.get_signal_address()) - DBHelper.reset_data() + if None not in (DBHelper.get_register_firstname(), + DBHelper.get_register_lastname(), + DBHelper.get_register_email(), + DBHelper.get_register_phone()): + Upload_Face.upload_your_face(DBHelper.get_register_firstname(), DBHelper.get_register_lastname(), + DBHelper.get_register_email(), DBHelper.get_register_phone()) + DBHelper.remove_register_data() diff --git a/Remove_Face.py b/Remove_Face.py new file mode 100644 index 000000000..68eed7683 --- /dev/null +++ b/Remove_Face.py @@ -0,0 +1,3 @@ +import DBHelper + +def remove_your_face(firstname, lastname, email, phone): \ No newline at end of file diff --git a/Upload_Face.py b/Upload_Face.py index 35c438ada..75f343e63 100644 --- a/Upload_Face.py +++ b/Upload_Face.py @@ -2,7 +2,7 @@ import DBHelper import Facial_Recognition_Registration -def upload_your_face(firstname, lastname, email, phone, address): +def upload_your_face(firstname, lastname, email, phone): # Determines user ID before adding the data to the database. # User 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 user ID. @@ -11,12 +11,12 @@ def upload_your_face(firstname, lastname, email, phone, address): count = 1 for user in users.each(): count += 1 - DBHelper.upload_data("User_" + str(count), firstname, lastname, email, phone, address) + DBHelper.upload_data("User_" + str(count), firstname, lastname, email, phone) Facial_Recognition_Registration.register_your_face("User_" + str(count)) for i in range(20): DBHelper.upload_user_photo("User_" + str(count) + "/" + str(i) + ".jpg") except: - DBHelper.upload_data("User_1", firstname, lastname, email, phone, address) + DBHelper.upload_data("User_1", firstname, lastname, email, phone) Facial_Recognition_Registration.register_your_face("User_1") for i in range(20): DBHelper.upload_user_photo("User_1/" + str(i) + ".jpg") @@ -27,5 +27,4 @@ if __name__ == "__main__": l = input('Enter your Last Name:') e = input('Enter your E-Mail:') p = input('Enter your Phone:') - a = input('Enter your Address:') - upload_your_face(f, l, e, p, a) + upload_your_face(f, l, e, p)