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

31 lines
1.1 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.
count = 0
users = DBHelper.db.child("Users").get()
try:
for x in users.each():
2020-11-07 03:57:24 +00:00
count = +1
for y in range(20):
if not os.path.isdir("Facial_images/face_rec/train/User_" + str(count)):
os.makedirs("Photos_of_Users/User_" + str(count))
DBHelper.download_user_photo("User_" + str(count) + "/" + str(y) + ".jpg")
2020-11-07 03:57:24 +00:00
except:
print("No Users are registered.")
count = 0
try:
for x in users.each():
2020-11-07 03:57:24 +00:00
count = +1
for y in range(20):
if not os.path.isdir("Photos_of_Thieves/Thief_" + str(count)):
os.makedirs("Photos_of_Thieves/Thief_" + str(count))
DBHelper.download_thief_photo("Thief_" + str(count) + "/" + str(y) + ".jpg")
2020-11-07 03:57:24 +00:00
except:
print("No Thieves for now.")
Facial_Recognition_Wrapper.training_recognizer("Fisher")
Facial_Recognition_Wrapper.face_recognition_inference("Fisher")