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

40 lines
1.4 KiB
Python
Raw Normal View History

import os
2020-11-07 03:57:24 +00:00
import DBHelper
import Facial_Recognition_Wrapper
2020-11-07 03:57:24 +00:00
2020-11-07 02:59:40 +00:00
def start():
2020-11-07 03:57:24 +00:00
# Downloads all the user and thief photos from database to the project folder first or updates them.
2020-11-16 18:17:54 +00:00
# Then it starts Facial Recognition Software.
2020-11-07 03:57:24 +00:00
users = DBHelper.db.child("Users").get()
2020-11-15 17:04:56 +00:00
thieves = DBHelper.db.child("Thieves").get()
2020-11-16 18:15:24 +00:00
print("Checking and updating User photos...")
2020-11-07 03:57:24 +00:00
try:
2020-11-18 18:18:51 +00:00
count = 0
2020-11-15 16:49:49 +00:00
for user in users.each():
2020-11-15 01:43:56 +00:00
count += 1
2020-11-15 16:49:49 +00:00
if not os.path.isdir("Facial_images/face_rec/train/User_" + str(count)):
os.makedirs("Facial_images/face_rec/train/User_" + str(count))
for i in range(20):
DBHelper.download_user_photo("User_" + str(count) + "/" + str(i) + ".jpg")
2020-11-16 18:15:24 +00:00
print("Success.")
2020-11-07 03:57:24 +00:00
except:
print("No Users are registered.")
count = 0
2020-11-16 18:15:24 +00:00
print("Checking and updating Thief photos...")
2020-11-07 03:57:24 +00:00
try:
2020-11-15 17:04:56 +00:00
for thief in thieves.each():
2020-11-15 01:43:56 +00:00
count += 1
2020-11-15 16:49:49 +00:00
if not os.path.isdir("Photos_of_Thieves/Thief_" + str(count)):
os.makedirs("Photos_of_Thieves/Thief_" + str(count))
for i in range(20):
DBHelper.download_thief_photo("Thief_" + str(count) + "/" + str(i) + ".jpg")
2020-11-16 18:15:24 +00:00
print("Success.")
2020-11-07 03:57:24 +00:00
except:
2020-11-16 18:15:24 +00:00
print("No Thieves are registered.")
Facial_Recognition_Wrapper.training_recognizer("Fisher")
2020-11-15 17:04:56 +00:00
Facial_Recognition_Wrapper.face_recognition_inference("Fisher")
2020-11-18 02:56:47 +00:00
if __name__ == "__main__":
start()