Vehicle-Anti-Theft-Face-Rec.../Upload_Thief.py

43 lines
1.6 KiB
Python
Raw Normal View History

2021-02-02 00:51:23 +00:00
import DBHelper
2021-02-04 22:41:59 +00:00
import Facial_Recognition_Thief_Registration
2021-02-02 00:51:23 +00:00
from datetime import datetime
from joblib import Parallel, delayed
import multiprocessing
2021-02-02 00:51:23 +00:00
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
2021-02-04 22:41:59 +00:00
Facial_Recognition_Thief_Registration.register_your_face("Thief_" + str(count))
Parallel(n_jobs=multiprocessing.cpu_count())(
delayed(upload_parallel_thief_photos)(i, count) for i in range(50))
2021-02-02 00:51:23 +00:00
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:
2021-02-04 22:41:59 +00:00
Facial_Recognition_Thief_Registration.register_your_face("Thief_1")
Parallel(n_jobs=multiprocessing.cpu_count())(
delayed(upload_parallel_thief_photo)(i) for i in range(50))
2021-02-02 00:51:23 +00:00
date = datetime.now().strftime("%d/%m/%Y")
time = datetime.now().strftime("%H:%M:%S")
2021-02-04 22:41:59 +00:00
DBHelper.upload_thief_data("Thief_1", date, time)
2021-02-02 00:51:23 +00:00
print("An intruder is recorded.")
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")
2021-03-21 17:37:41 +00:00
if __name__ == "__main__":
upload_thief_face()