Added the thief detection function.

This commit is contained in:
Batuhan Berk Başoğlu 2021-02-01 19:51:23 -05:00
parent e4ffc1b241
commit be4752b619
9 changed files with 69 additions and 3 deletions

View file

@ -214,5 +214,12 @@ def remove_removal_data():
db.child("signal").child("3").remove()
# Uploads the data of specified thief into firebase.
def upload_thief_data(thief_id, date, time):
data = {"Date": date, "Time": time}
db.child("Thieves").child(thief_id).set(data)
if __name__ == "__main__":
upload_data("User_3", "RandomFirst", "RandomLast", "Random@gmail.com", "0000000000")
upload_register_data("RandomFirst", "RandomLast", "Random@gmail.com", "0000000000")
upload_removal_data("RandomFirst", "RandomLast", "Random@gmail.com", "0000000000")

View file

@ -3,6 +3,9 @@ import dlib
import cv2
import numpy as np
import DBHelper
import time
import Upload_Thief
def inference():
try:
@ -30,6 +33,7 @@ def inference():
x1 = x2 = y1 = y2 = 0
cond = False
t = 0
while DBHelper.get_power() == "on":
t = time.time()
@ -97,10 +101,16 @@ def inference():
elif not cond:
DBHelper.set_motor("off")
DBHelper.set_alarm("on")
t += 1
time.sleep(1)
if t == 120:
Upload_Thief.upload_thief_face()
DBHelper.set_power("off")
DBHelper.set_alarm("off")
DBHelper.set_motor("off")
cv2.destroyAllWindows()
if __name__ == "__main__":
inference()

6
UI/.idea/compiler.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="1.8" />
</component>
</project>

View file

@ -14,6 +14,7 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View file

@ -24,9 +24,14 @@ def upload_your_face(firstname, lastname, email, phone):
print("Success.")
except:
DBHelper.upload_data("User_1", firstname, lastname, email, phone)
print("Face registration start...")
Facial_Recognition_Registration.register_your_face("User_1")
print("Data saved! Starting enrollment...")
Facial_Recognition_Enrollment.enroll_face_dataset()
print("Face registration completed!")
for i in range(50):
DBHelper.upload_user_photo("User_1/" + str(i) + ".jpg")
print("Success.")
if __name__ == "__main__":

37
Upload_Thief.py Normal file
View file

@ -0,0 +1,37 @@
import DBHelper
import Facial_Recognition_Registration
import Facial_Recognition_Enrollment
from datetime import datetime
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
Facial_Recognition_Registration.register_your_face("Thief_" + str(count))
Facial_Recognition_Enrollment.enroll_face_dataset()
for i in range(50):
DBHelper.upload_thief_photo("Thief_" + str(count) + "/" + str(i) + ".jpg")
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:
DBHelper.upload_thief_data("Thief_1", date, time)
Facial_Recognition_Registration.register_your_face("Thief_1")
Facial_Recognition_Enrollment.enroll_face_dataset()
for i in range(50):
DBHelper.upload_thief_photo("Thief_1/" + str(i) + ".jpg")
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.")
if __name__ == "__main__":
upload_thief_face()

Binary file not shown.