Added the update function.
34
DBHelper.py
|
@ -234,6 +234,40 @@ def get_date(thief_id):
|
|||
phone = db.child("Thieves").child(str(thief_id)).child("Date").get().val()
|
||||
return phone
|
||||
|
||||
# Returns the first name or else an empty string.
|
||||
def get_update_firstname():
|
||||
firstname = db.child("signal").child("4").child("First Name").get().val()
|
||||
return firstname
|
||||
|
||||
|
||||
# Returns the last name or else an empty string.
|
||||
def get_update_lastname():
|
||||
lastname = db.child("signal").child("4").child("Last Name").get().val()
|
||||
return lastname
|
||||
|
||||
|
||||
# Returns the e-mail or else an empty string.
|
||||
def get_update_email():
|
||||
email = db.child("signal").child("4").child("E-Mail").get().val()
|
||||
return email
|
||||
|
||||
|
||||
# Returns the phone or else an empty string.
|
||||
def get_update_phone():
|
||||
phone = db.child("signal").child("4").child("Phone").get().val()
|
||||
return phone
|
||||
|
||||
|
||||
# Uploads the data of user input into firebase.
|
||||
def upload_update_data(firstname, lastname, email, phone):
|
||||
data = {"First Name": firstname, "Last Name": lastname, "E-Mail": email, "Phone": phone}
|
||||
db.child("signal").child("4").set(data)
|
||||
|
||||
|
||||
# Removes the inputs.
|
||||
def remove_update_data():
|
||||
db.child("signal").child("4").remove()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
upload_data("User_3", "RandomFirst", "RandomLast", "Random@gmail.com", "0000000000")
|
||||
|
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 75 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 81 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 81 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 81 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 83 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 79 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 75 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 83 KiB |
9
Main.py
|
@ -3,6 +3,7 @@ import Start_Engine
|
|||
import Upload_Face
|
||||
import Remove_Face
|
||||
import Check_Up
|
||||
import Update
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Must do the check up First, this may take long...")
|
||||
|
@ -27,3 +28,11 @@ if __name__ == "__main__":
|
|||
Remove_Face.remove_your_face(DBHelper.get_removal_firstname(), DBHelper.get_removal_lastname(),
|
||||
DBHelper.get_removal_email(), DBHelper.get_removal_phone())
|
||||
DBHelper.remove_removal_data()
|
||||
|
||||
if None not in (DBHelper.get_update_firstname(),
|
||||
DBHelper.get_update_lastname(),
|
||||
DBHelper.get_update_email(),
|
||||
DBHelper.get_update_phone()):
|
||||
Update.update_your_face(DBHelper.get_update_firstname(), DBHelper.get_update_lastname(),
|
||||
DBHelper.get_update_email(), DBHelper.get_update_phone())
|
||||
DBHelper.remove_update_data()
|
||||
|
|
|
@ -59,14 +59,6 @@ def remove_your_face(firstname, lastname, email, phone):
|
|||
print("No Users exist for User Removal.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
f = input('Enter your First Name:')
|
||||
l = input('Enter your Last Name:')
|
||||
e = input('Enter your E-Mail:')
|
||||
p = input('Enter your Phone:')
|
||||
remove_your_face(f, l, e, p)
|
||||
|
||||
|
||||
def remove_parallel_user_photos(i, count2):
|
||||
DBHelper.delete_user_photo("User_" + str(count2) + "/" + str(i) + ".jpg")
|
||||
|
||||
|
@ -75,4 +67,12 @@ def update_parallel_user_photos(i, count2):
|
|||
DBHelper.download_user_photo_other("User_" + str(count2 + 1) + "/" + str(i) + ".jpg",
|
||||
"User_" + str(count2) + "/" + str(i) + ".jpg")
|
||||
DBHelper.upload_user_photo("User_" + str(count2) + "/" + str(i) + ".jpg")
|
||||
DBHelper.delete_user_photo("User_" + str(count2 + 1) + "/" + str(i) + ".jpg")
|
||||
DBHelper.delete_user_photo("User_" + str(count2 + 1) + "/" + str(i) + ".jpg")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
f = input('Enter your First Name:')
|
||||
l = input('Enter your Last Name:')
|
||||
e = input('Enter your E-Mail:')
|
||||
p = input('Enter your Phone:')
|
||||
remove_your_face(f, l, e, p)
|
42
Update.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
import DBHelper
|
||||
import Facial_Recognition_Registration
|
||||
import Facial_Recognition_Enrollment
|
||||
from joblib import Parallel, delayed
|
||||
import multiprocessing
|
||||
|
||||
|
||||
def update_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.
|
||||
users = DBHelper.db.child("Users").get()
|
||||
print("Updating the User information...")
|
||||
try:
|
||||
count = 0
|
||||
for user in users.each():
|
||||
count += 1
|
||||
if DBHelper.get_email("User_" + str(count)) == email:
|
||||
break
|
||||
print("Face registration start...")
|
||||
Facial_Recognition_Registration.register_your_face("User_" + str(count))
|
||||
Parallel(n_jobs=multiprocessing.cpu_count())(delayed(update_parallel_user_photos)(i, count) for i in range(50))
|
||||
DBHelper.upload_data("User_" + str(count), firstname, lastname, email, phone)
|
||||
print("Data saved! Starting enrollment...")
|
||||
Facial_Recognition_Enrollment.enroll_face_dataset()
|
||||
print("Face registration completed!")
|
||||
print("Success.")
|
||||
except:
|
||||
print("It seems there is no user registered.")
|
||||
|
||||
|
||||
def update_parallel_user_photos(i, count):
|
||||
DBHelper.delete_user_photo("User_" + str(count) + "/" + str(i) + ".jpg")
|
||||
DBHelper.upload_user_photo("User_" + str(count) + "/" + str(i) + ".jpg")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
f = input('Enter your First Name:')
|
||||
l = input('Enter your Last Name:')
|
||||
e = input('Enter your E-Mail:')
|
||||
p = input('Enter your Phone:')
|
||||
update_your_face(f, l, e, p)
|
|
@ -36,17 +36,17 @@ def upload_your_face(firstname, lastname, email, phone):
|
|||
print("Success.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
f = input('Enter your First Name:')
|
||||
l = input('Enter your Last Name:')
|
||||
e = input('Enter your E-Mail:')
|
||||
p = input('Enter your Phone:')
|
||||
upload_your_face(f, l, e, p)
|
||||
|
||||
|
||||
def upload_parallel_user_photos(i, count):
|
||||
DBHelper.upload_user_photo("User_" + str(count) + "/" + str(i) + ".jpg")
|
||||
|
||||
|
||||
def upload_parallel_user_photo(i):
|
||||
DBHelper.upload_user_photo("User_1/" + str(i) + ".jpg")
|
||||
DBHelper.upload_user_photo("User_1/" + str(i) + ".jpg")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
f = input('Enter your First Name:')
|
||||
l = input('Enter your Last Name:')
|
||||
e = input('Enter your E-Mail:')
|
||||
p = input('Enter your Phone:')
|
||||
upload_your_face(f, l, e, p)
|
|
@ -31,13 +31,13 @@ def upload_thief_face():
|
|||
print("An intruder is recorded.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
upload_thief_face()
|
||||
|
||||
|
||||
def upload_parallel_thief_photos(i, count):
|
||||
DBHelper.upload_thief_photo("Thief_" + str(count) + "/" + str(i) + ".jpg")
|
||||
|
||||
|
||||
def upload_parallel_thief_photo(i):
|
||||
DBHelper.upload_thief_photo("Thief_1/" + str(i) + ".jpg")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
upload_thief_face()
|