Added the thief detection function.
This commit is contained in:
parent
e4ffc1b241
commit
be4752b619
9 changed files with 69 additions and 3 deletions
|
@ -214,5 +214,12 @@ def remove_removal_data():
|
||||||
db.child("signal").child("3").remove()
|
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__":
|
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")
|
||||||
|
|
|
@ -3,6 +3,9 @@ import dlib
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import DBHelper
|
import DBHelper
|
||||||
|
import time
|
||||||
|
import Upload_Thief
|
||||||
|
|
||||||
|
|
||||||
def inference():
|
def inference():
|
||||||
try:
|
try:
|
||||||
|
@ -30,6 +33,7 @@ def inference():
|
||||||
x1 = x2 = y1 = y2 = 0
|
x1 = x2 = y1 = y2 = 0
|
||||||
|
|
||||||
cond = False
|
cond = False
|
||||||
|
t = 0
|
||||||
|
|
||||||
while DBHelper.get_power() == "on":
|
while DBHelper.get_power() == "on":
|
||||||
t = time.time()
|
t = time.time()
|
||||||
|
@ -97,10 +101,16 @@ def inference():
|
||||||
elif not cond:
|
elif not cond:
|
||||||
DBHelper.set_motor("off")
|
DBHelper.set_motor("off")
|
||||||
DBHelper.set_alarm("on")
|
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_alarm("off")
|
||||||
DBHelper.set_motor("off")
|
DBHelper.set_motor("off")
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
inference()
|
inference()
|
||||||
|
|
6
UI/.idea/compiler.xml
Normal file
6
UI/.idea/compiler.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="1.8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -14,6 +14,7 @@
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
|
<option name="useQualifiedModuleNames" value="true" />
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<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" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -24,9 +24,14 @@ def upload_your_face(firstname, lastname, email, phone):
|
||||||
print("Success.")
|
print("Success.")
|
||||||
except:
|
except:
|
||||||
DBHelper.upload_data("User_1", firstname, lastname, email, phone)
|
DBHelper.upload_data("User_1", firstname, lastname, email, phone)
|
||||||
|
print("Face registration start...")
|
||||||
Facial_Recognition_Registration.register_your_face("User_1")
|
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):
|
for i in range(50):
|
||||||
DBHelper.upload_user_photo("User_1/" + str(i) + ".jpg")
|
DBHelper.upload_user_photo("User_1/" + str(i) + ".jpg")
|
||||||
|
print("Success.")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
37
Upload_Thief.py
Normal file
37
Upload_Thief.py
Normal 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.
Binary file not shown.
Loading…
Reference in a new issue