diff --git a/DBHelper.py b/DBHelper.py index 5c6673cd3..38843546a 100644 --- a/DBHelper.py +++ b/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") diff --git a/Facial_images/face_rec/train/User_1/0.jpg b/Facial_images/face_rec/train/User_1/0.jpg index 79016d11f..5d83ee139 100644 Binary files a/Facial_images/face_rec/train/User_1/0.jpg and b/Facial_images/face_rec/train/User_1/0.jpg differ diff --git a/Facial_images/face_rec/train/User_1/1.jpg b/Facial_images/face_rec/train/User_1/1.jpg index b83310775..83b50dcda 100644 Binary files a/Facial_images/face_rec/train/User_1/1.jpg and b/Facial_images/face_rec/train/User_1/1.jpg differ diff --git a/Facial_images/face_rec/train/User_1/10.jpg b/Facial_images/face_rec/train/User_1/10.jpg index 1dcfa0463..6e5a5e4a0 100644 Binary files a/Facial_images/face_rec/train/User_1/10.jpg and b/Facial_images/face_rec/train/User_1/10.jpg differ diff --git a/Facial_images/face_rec/train/User_1/11.jpg b/Facial_images/face_rec/train/User_1/11.jpg index bae7468a4..c3310200c 100644 Binary files a/Facial_images/face_rec/train/User_1/11.jpg and b/Facial_images/face_rec/train/User_1/11.jpg differ diff --git a/Facial_images/face_rec/train/User_1/12.jpg b/Facial_images/face_rec/train/User_1/12.jpg index 1b158d22d..6fc791efa 100644 Binary files a/Facial_images/face_rec/train/User_1/12.jpg and b/Facial_images/face_rec/train/User_1/12.jpg differ diff --git a/Facial_images/face_rec/train/User_1/13.jpg b/Facial_images/face_rec/train/User_1/13.jpg index 8a922dfb8..9e2f28188 100644 Binary files a/Facial_images/face_rec/train/User_1/13.jpg and b/Facial_images/face_rec/train/User_1/13.jpg differ diff --git a/Facial_images/face_rec/train/User_1/14.jpg b/Facial_images/face_rec/train/User_1/14.jpg index 8701d8e96..c09cc8d72 100644 Binary files a/Facial_images/face_rec/train/User_1/14.jpg and b/Facial_images/face_rec/train/User_1/14.jpg differ diff --git a/Facial_images/face_rec/train/User_1/15.jpg b/Facial_images/face_rec/train/User_1/15.jpg index 390538706..38af72ccd 100644 Binary files a/Facial_images/face_rec/train/User_1/15.jpg and b/Facial_images/face_rec/train/User_1/15.jpg differ diff --git a/Facial_images/face_rec/train/User_1/16.jpg b/Facial_images/face_rec/train/User_1/16.jpg index 84e5a53d0..abbecdec4 100644 Binary files a/Facial_images/face_rec/train/User_1/16.jpg and b/Facial_images/face_rec/train/User_1/16.jpg differ diff --git a/Facial_images/face_rec/train/User_1/17.jpg b/Facial_images/face_rec/train/User_1/17.jpg index 3f8605e29..f81983d6a 100644 Binary files a/Facial_images/face_rec/train/User_1/17.jpg and b/Facial_images/face_rec/train/User_1/17.jpg differ diff --git a/Facial_images/face_rec/train/User_1/18.jpg b/Facial_images/face_rec/train/User_1/18.jpg index dbcdabeed..70318b443 100644 Binary files a/Facial_images/face_rec/train/User_1/18.jpg and b/Facial_images/face_rec/train/User_1/18.jpg differ diff --git a/Facial_images/face_rec/train/User_1/19.jpg b/Facial_images/face_rec/train/User_1/19.jpg index 7a86099e2..c699b3c63 100644 Binary files a/Facial_images/face_rec/train/User_1/19.jpg and b/Facial_images/face_rec/train/User_1/19.jpg differ diff --git a/Facial_images/face_rec/train/User_1/2.jpg b/Facial_images/face_rec/train/User_1/2.jpg index 200e259b6..ba671e140 100644 Binary files a/Facial_images/face_rec/train/User_1/2.jpg and b/Facial_images/face_rec/train/User_1/2.jpg differ diff --git a/Facial_images/face_rec/train/User_1/20.jpg b/Facial_images/face_rec/train/User_1/20.jpg index e3c10e9c8..ed4753934 100644 Binary files a/Facial_images/face_rec/train/User_1/20.jpg and b/Facial_images/face_rec/train/User_1/20.jpg differ diff --git a/Facial_images/face_rec/train/User_1/21.jpg b/Facial_images/face_rec/train/User_1/21.jpg index 7c167eb2a..133866675 100644 Binary files a/Facial_images/face_rec/train/User_1/21.jpg and b/Facial_images/face_rec/train/User_1/21.jpg differ diff --git a/Facial_images/face_rec/train/User_1/22.jpg b/Facial_images/face_rec/train/User_1/22.jpg index 8f2d660fb..fcb3b7cfb 100644 Binary files a/Facial_images/face_rec/train/User_1/22.jpg and b/Facial_images/face_rec/train/User_1/22.jpg differ diff --git a/Facial_images/face_rec/train/User_1/23.jpg b/Facial_images/face_rec/train/User_1/23.jpg index 9ee140478..4864e663e 100644 Binary files a/Facial_images/face_rec/train/User_1/23.jpg and b/Facial_images/face_rec/train/User_1/23.jpg differ diff --git a/Facial_images/face_rec/train/User_1/24.jpg b/Facial_images/face_rec/train/User_1/24.jpg index 9ed0fc6b1..acc5dc7cd 100644 Binary files a/Facial_images/face_rec/train/User_1/24.jpg and b/Facial_images/face_rec/train/User_1/24.jpg differ diff --git a/Facial_images/face_rec/train/User_1/25.jpg b/Facial_images/face_rec/train/User_1/25.jpg index 5bcb7c25b..e2368aba6 100644 Binary files a/Facial_images/face_rec/train/User_1/25.jpg and b/Facial_images/face_rec/train/User_1/25.jpg differ diff --git a/Facial_images/face_rec/train/User_1/26.jpg b/Facial_images/face_rec/train/User_1/26.jpg index 736bc89a4..26728240c 100644 Binary files a/Facial_images/face_rec/train/User_1/26.jpg and b/Facial_images/face_rec/train/User_1/26.jpg differ diff --git a/Facial_images/face_rec/train/User_1/27.jpg b/Facial_images/face_rec/train/User_1/27.jpg index c2f95929e..d859b9a8e 100644 Binary files a/Facial_images/face_rec/train/User_1/27.jpg and b/Facial_images/face_rec/train/User_1/27.jpg differ diff --git a/Facial_images/face_rec/train/User_1/28.jpg b/Facial_images/face_rec/train/User_1/28.jpg index fed9f8f95..b72eac8ba 100644 Binary files a/Facial_images/face_rec/train/User_1/28.jpg and b/Facial_images/face_rec/train/User_1/28.jpg differ diff --git a/Facial_images/face_rec/train/User_1/29.jpg b/Facial_images/face_rec/train/User_1/29.jpg index cfc71d4de..41a2ecf1a 100644 Binary files a/Facial_images/face_rec/train/User_1/29.jpg and b/Facial_images/face_rec/train/User_1/29.jpg differ diff --git a/Facial_images/face_rec/train/User_1/3.jpg b/Facial_images/face_rec/train/User_1/3.jpg index 8f1cd3dbf..a33b7b854 100644 Binary files a/Facial_images/face_rec/train/User_1/3.jpg and b/Facial_images/face_rec/train/User_1/3.jpg differ diff --git a/Facial_images/face_rec/train/User_1/30.jpg b/Facial_images/face_rec/train/User_1/30.jpg index be1c3cf65..88098f6cc 100644 Binary files a/Facial_images/face_rec/train/User_1/30.jpg and b/Facial_images/face_rec/train/User_1/30.jpg differ diff --git a/Facial_images/face_rec/train/User_1/31.jpg b/Facial_images/face_rec/train/User_1/31.jpg index d255a1df4..077721c72 100644 Binary files a/Facial_images/face_rec/train/User_1/31.jpg and b/Facial_images/face_rec/train/User_1/31.jpg differ diff --git a/Facial_images/face_rec/train/User_1/32.jpg b/Facial_images/face_rec/train/User_1/32.jpg index d5dcbf09f..7c3212c22 100644 Binary files a/Facial_images/face_rec/train/User_1/32.jpg and b/Facial_images/face_rec/train/User_1/32.jpg differ diff --git a/Facial_images/face_rec/train/User_1/33.jpg b/Facial_images/face_rec/train/User_1/33.jpg index 4d5557a71..fa1779d1f 100644 Binary files a/Facial_images/face_rec/train/User_1/33.jpg and b/Facial_images/face_rec/train/User_1/33.jpg differ diff --git a/Facial_images/face_rec/train/User_1/34.jpg b/Facial_images/face_rec/train/User_1/34.jpg index 08d36de78..0107393d6 100644 Binary files a/Facial_images/face_rec/train/User_1/34.jpg and b/Facial_images/face_rec/train/User_1/34.jpg differ diff --git a/Facial_images/face_rec/train/User_1/35.jpg b/Facial_images/face_rec/train/User_1/35.jpg index 0b938aac7..ca985c0ac 100644 Binary files a/Facial_images/face_rec/train/User_1/35.jpg and b/Facial_images/face_rec/train/User_1/35.jpg differ diff --git a/Facial_images/face_rec/train/User_1/36.jpg b/Facial_images/face_rec/train/User_1/36.jpg index c710d7902..13e4141dc 100644 Binary files a/Facial_images/face_rec/train/User_1/36.jpg and b/Facial_images/face_rec/train/User_1/36.jpg differ diff --git a/Facial_images/face_rec/train/User_1/37.jpg b/Facial_images/face_rec/train/User_1/37.jpg index 16c1e394a..a228d9d61 100644 Binary files a/Facial_images/face_rec/train/User_1/37.jpg and b/Facial_images/face_rec/train/User_1/37.jpg differ diff --git a/Facial_images/face_rec/train/User_1/38.jpg b/Facial_images/face_rec/train/User_1/38.jpg index 1388b4d65..83fa96294 100644 Binary files a/Facial_images/face_rec/train/User_1/38.jpg and b/Facial_images/face_rec/train/User_1/38.jpg differ diff --git a/Facial_images/face_rec/train/User_1/39.jpg b/Facial_images/face_rec/train/User_1/39.jpg index 5545d430f..5d14124f1 100644 Binary files a/Facial_images/face_rec/train/User_1/39.jpg and b/Facial_images/face_rec/train/User_1/39.jpg differ diff --git a/Facial_images/face_rec/train/User_1/4.jpg b/Facial_images/face_rec/train/User_1/4.jpg index d8840ec1f..1863aab96 100644 Binary files a/Facial_images/face_rec/train/User_1/4.jpg and b/Facial_images/face_rec/train/User_1/4.jpg differ diff --git a/Facial_images/face_rec/train/User_1/40.jpg b/Facial_images/face_rec/train/User_1/40.jpg index c782d5b5d..e1862a579 100644 Binary files a/Facial_images/face_rec/train/User_1/40.jpg and b/Facial_images/face_rec/train/User_1/40.jpg differ diff --git a/Facial_images/face_rec/train/User_1/41.jpg b/Facial_images/face_rec/train/User_1/41.jpg index c6ec5dfd1..ad7d40d78 100644 Binary files a/Facial_images/face_rec/train/User_1/41.jpg and b/Facial_images/face_rec/train/User_1/41.jpg differ diff --git a/Facial_images/face_rec/train/User_1/42.jpg b/Facial_images/face_rec/train/User_1/42.jpg index 99da175d0..03aac1d44 100644 Binary files a/Facial_images/face_rec/train/User_1/42.jpg and b/Facial_images/face_rec/train/User_1/42.jpg differ diff --git a/Facial_images/face_rec/train/User_1/43.jpg b/Facial_images/face_rec/train/User_1/43.jpg index b04860585..833b9d24a 100644 Binary files a/Facial_images/face_rec/train/User_1/43.jpg and b/Facial_images/face_rec/train/User_1/43.jpg differ diff --git a/Facial_images/face_rec/train/User_1/44.jpg b/Facial_images/face_rec/train/User_1/44.jpg index d2bf71550..4b90ca7dd 100644 Binary files a/Facial_images/face_rec/train/User_1/44.jpg and b/Facial_images/face_rec/train/User_1/44.jpg differ diff --git a/Facial_images/face_rec/train/User_1/45.jpg b/Facial_images/face_rec/train/User_1/45.jpg index 67d725b72..a286af2ad 100644 Binary files a/Facial_images/face_rec/train/User_1/45.jpg and b/Facial_images/face_rec/train/User_1/45.jpg differ diff --git a/Facial_images/face_rec/train/User_1/46.jpg b/Facial_images/face_rec/train/User_1/46.jpg index bb7e2f7c4..798bc53dd 100644 Binary files a/Facial_images/face_rec/train/User_1/46.jpg and b/Facial_images/face_rec/train/User_1/46.jpg differ diff --git a/Facial_images/face_rec/train/User_1/47.jpg b/Facial_images/face_rec/train/User_1/47.jpg index 6eef48313..c8285b216 100644 Binary files a/Facial_images/face_rec/train/User_1/47.jpg and b/Facial_images/face_rec/train/User_1/47.jpg differ diff --git a/Facial_images/face_rec/train/User_1/48.jpg b/Facial_images/face_rec/train/User_1/48.jpg index 71fe221a5..55fa7d9ac 100644 Binary files a/Facial_images/face_rec/train/User_1/48.jpg and b/Facial_images/face_rec/train/User_1/48.jpg differ diff --git a/Facial_images/face_rec/train/User_1/49.jpg b/Facial_images/face_rec/train/User_1/49.jpg index 0a2a184f1..6d9395102 100644 Binary files a/Facial_images/face_rec/train/User_1/49.jpg and b/Facial_images/face_rec/train/User_1/49.jpg differ diff --git a/Facial_images/face_rec/train/User_1/5.jpg b/Facial_images/face_rec/train/User_1/5.jpg index 2e44859af..21ecce667 100644 Binary files a/Facial_images/face_rec/train/User_1/5.jpg and b/Facial_images/face_rec/train/User_1/5.jpg differ diff --git a/Facial_images/face_rec/train/User_1/6.jpg b/Facial_images/face_rec/train/User_1/6.jpg index a388c2916..910438bbd 100644 Binary files a/Facial_images/face_rec/train/User_1/6.jpg and b/Facial_images/face_rec/train/User_1/6.jpg differ diff --git a/Facial_images/face_rec/train/User_1/7.jpg b/Facial_images/face_rec/train/User_1/7.jpg index 33821b320..d351974b9 100644 Binary files a/Facial_images/face_rec/train/User_1/7.jpg and b/Facial_images/face_rec/train/User_1/7.jpg differ diff --git a/Facial_images/face_rec/train/User_1/8.jpg b/Facial_images/face_rec/train/User_1/8.jpg index 9c63cbfca..b8d9fce60 100644 Binary files a/Facial_images/face_rec/train/User_1/8.jpg and b/Facial_images/face_rec/train/User_1/8.jpg differ diff --git a/Facial_images/face_rec/train/User_1/9.jpg b/Facial_images/face_rec/train/User_1/9.jpg index 0ed70a312..8c9a53304 100644 Binary files a/Facial_images/face_rec/train/User_1/9.jpg and b/Facial_images/face_rec/train/User_1/9.jpg differ diff --git a/Facial_models/descriptors.npy b/Facial_models/descriptors.npy index 92e3010aa..48f23b639 100644 Binary files a/Facial_models/descriptors.npy and b/Facial_models/descriptors.npy differ diff --git a/Facial_models/index.pkl b/Facial_models/index.pkl index dba118d62..37b326565 100644 Binary files a/Facial_models/index.pkl and b/Facial_models/index.pkl differ diff --git a/Main.py b/Main.py index f956fa105..02aa4af7a 100644 --- a/Main.py +++ b/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() diff --git a/Remove_Face.py b/Remove_Face.py index 957ff8801..52c0a9d80 100644 --- a/Remove_Face.py +++ b/Remove_Face.py @@ -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") \ No newline at end of file + 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) \ No newline at end of file diff --git a/Update.py b/Update.py new file mode 100644 index 000000000..c0fff3784 --- /dev/null +++ b/Update.py @@ -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) \ No newline at end of file diff --git a/Upload_Face.py b/Upload_Face.py index 8a13ab6b2..6ab3e5dc9 100644 --- a/Upload_Face.py +++ b/Upload_Face.py @@ -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") \ No newline at end of file + 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) \ No newline at end of file diff --git a/Upload_Thief.py b/Upload_Thief.py index a5f429a50..168534c50 100644 --- a/Upload_Thief.py +++ b/Upload_Thief.py @@ -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() \ No newline at end of file diff --git a/__pycache__/DBHelper.cpython-36.pyc b/__pycache__/DBHelper.cpython-36.pyc index 2ec2a1e30..67caf0393 100644 Binary files a/__pycache__/DBHelper.cpython-36.pyc and b/__pycache__/DBHelper.cpython-36.pyc differ diff --git a/__pycache__/Update.cpython-36.pyc b/__pycache__/Update.cpython-36.pyc new file mode 100644 index 000000000..3d9352fb3 Binary files /dev/null and b/__pycache__/Update.cpython-36.pyc differ