Finalized the code.

This commit is contained in:
Batuhan Berk Başoğlu 2020-11-19 11:58:04 -05:00
parent 17e04d8029
commit c3d1f605d7
7 changed files with 88225 additions and 102556 deletions

View file

@ -111,71 +111,71 @@ def delete_thief_photo(user_photo):
# Motor signal getter # Motor signal getter
def get_motor(): def get_motor():
motor = db.child("signal").child("1").child("motor").get().val() motor = db.child("signal").child("motor").get().val()
return motor return motor
# Motor signal setter # Motor signal setter
def set_motor(motor): def set_motor(motor):
db.child("signal").child("1").child("motor").set(motor) db.child("signal").child("motor").set(motor)
# Alarm signal getter # Alarm signal getter
def get_alarm(): def get_alarm():
alarm = db.child("signal").child("1").child("alarm").get().val() alarm = db.child("signal").child("alarm").get().val()
return alarm return alarm
# Alarm signal setter # Alarm signal setter
def set_alarm(alarm): def set_alarm(alarm):
db.child("signal").child("1").child("alarm").set(alarm) db.child("signal").child("alarm").set(alarm)
# Power signal getter # Power signal getter
def get_power(): def get_power():
alarm = db.child("signal").child("1").child("power").get().val() alarm = db.child("signal").child("power").get().val()
return alarm return alarm
# Power signal setter # Power signal setter
def set_power(power): def set_power(power):
db.child("signal").child("1").child("power").set(power) db.child("signal").child("power").set(power)
# Returns the first name or else an empty string. # Returns the first name or else an empty string.
def get_signal_firstname(): def get_signal_firstname():
firstname = db.child("signal").child("2").child("First Name").get().val() firstname = db.child("signal_2").child("First Name").get().val()
return firstname return firstname
# Returns the last name or else an empty string. # Returns the last name or else an empty string.
def get_signal_lastname(): def get_signal_lastname():
lastname = db.child("signal").child("2").child("Last Name").get().val() lastname = db.child("signal_2").child("Last Name").get().val()
return lastname return lastname
# Returns the e-mail or else an empty string. # Returns the e-mail or else an empty string.
def get_signal_email(): def get_signal_email():
email = db.child("signal").child("2").child("E-Mail").get().val() email = db.child("signal_2").child("E-Mail").get().val()
return email return email
# Returns the phone or else an empty string. # Returns the phone or else an empty string.
def get_signal_phone(): def get_signal_phone():
phone = db.child("signal").child("2").child("Phone").get().val() phone = db.child("signal_2").child("Phone").get().val()
return phone return phone
# Returns the address or else an empty string. # Returns the address or else an empty string.
def get_signal_address(): def get_signal_address():
address = db.child("signal").child("2").child("Address").get().val() address = db.child("signal_2").child("Address").get().val()
return address return address
# Uploads the data of user input into firebase. # Uploads the data of user input into firebase.
def upload_signal_data(firstname, lastname, email, phone, address): def upload_signal_data(firstname, lastname, email, phone, address):
data = {"First Name": firstname, "Last Name": lastname, "E-Mail": email, "Phone": phone, "Address": address} data = {"First Name": firstname, "Last Name": lastname, "E-Mail": email, "Phone": phone, "Address": address}
db.child("signal").child("2").set(data) db.child("signal_2").set(data)
# Removes the inputs. # Removes the inputs.

View file

@ -8,7 +8,6 @@ import Facial_Recognition_Render as fr
import _pickle as cPickle import _pickle as cPickle
import glob import glob
import DBHelper import DBHelper
import Hardware.Updated_HW_codes.NewMotorFunc # Line 225-228
faceWidth = 320 faceWidth = 320
faceHeight = 320 faceHeight = 320
@ -200,7 +199,9 @@ def face_recognition_inference(rec_type):
landmarks = fr.getLandmarks(faceDetector, landmarkDetector, im) landmarks = fr.getLandmarks(faceDetector, landmarkDetector, im)
landmarks = np.array(landmarks) landmarks = np.array(landmarks)
while len(landmarks) == 68: cond = False
if len(landmarks) == 68:
x1Limit = landmarks[0][0] - (landmarks[36][0] - landmarks[0][0]) x1Limit = landmarks[0][0] - (landmarks[36][0] - landmarks[0][0])
x2Limit = landmarks[16][0] + (landmarks[16][0] - landmarks[45][0]) x2Limit = landmarks[16][0] + (landmarks[16][0] - landmarks[45][0])
y1Limit = landmarks[27][1] - 3 * (landmarks[30][1] - landmarks[27][1]) y1Limit = landmarks[27][1] - 3 * (landmarks[30][1] - landmarks[27][1])
@ -223,22 +224,28 @@ def face_recognition_inference(rec_type):
text = '{} {}%'.format(labelsMap[predictedLabel], round(score, 5)) text = '{} {}%'.format(labelsMap[predictedLabel], round(score, 5))
cv2.rectangle(original, (x1, y1), (x2, y2), (0, 255, 0), 5) cv2.rectangle(original, (x1, y1), (x2, y2), (0, 255, 0), 5)
cv2.putText(original, text, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 255, 0), 3) cv2.putText(original, text, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 255, 0), 3)
cond = True
if cond:
DBHelper.set_motor("on") DBHelper.set_motor("on")
Hardware.Updated_HW_codes.NewMotorFunc.Motor.start_motor() DBHelper.set_alarm("off")
else:
DBHelper.set_motor("off")
DBHelper.set_alarm("on") DBHelper.set_alarm("on")
Hardware.Updated_HW_codes.NewMotorFunc.Motor.start_alarm()
cv2.imshow('Face Recognition Demo', original) cv2.imshow('Face Recognition Demo', original)
k = cv2.waitKey(10) k = cv2.waitKey(10)
DBHelper.set_alarm("off")
DBHelper.set_motor("off")
cam.release() cam.release()
cv2.destroyAllWindows() cv2.destroyAllWindows()
if __name__ == "__main__": if __name__ == "__main__":
mode = 'test' mode = 'test'
rec_type = 'Fisher' # 'LBPH' 'Fisher' 'Eigen' rec_type = 'LBPH' # 'LBPH' 'Fisher' 'Eigen'
if mode == 'train': if mode == 'train':
training_recognizer(rec_type) training_recognizer(rec_type)

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -32,8 +32,8 @@ def start():
print("Success.") print("Success.")
except: except:
print("No Thieves are registered.") print("No Thieves are registered.")
Facial_Recognition_Wrapper.training_recognizer("Fisher") Facial_Recognition_Wrapper.training_recognizer("LBPH")
Facial_Recognition_Wrapper.face_recognition_inference("Fisher") Facial_Recognition_Wrapper.face_recognition_inference("LBPH")
if __name__ == "__main__": if __name__ == "__main__":