-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecurity.py
51 lines (39 loc) · 1.4 KB
/
security.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#This code will run a camera security system that sends alerts about recognized people via telegram.
#The goal is to eventually incorperate the ability to dynamically take snapshots of Unknown indeviduals and add them to the directory
import face_recognition
import picamera
import numpy as np
import os
import scipy.misc
import telegram_send as ts
import imageio
import shutil
import time
import logging
logging_fmt = '[%(asctime)s] %(filename)s [%(levelname)s] %(message)s'
logging.basicConfig(filename='security.log', filemode='w', format=logging_fmt, level=logging.INFO)
import facial_recognition_handler
import telegram_security
#test ID =-354289193
def main():
TOKEN="913604198:AAGjGty2I0vkPV-gkA2jkpIUrDJcTeAxXnc"
ID="-354289193"
ts=telegram_security.telegram_security(TOKEN, ID)
print("started telegram bot")
fr=facial_recognition_handler.recognition_handler()
print("Begin")
while True:
try:
detected_dict=fr.classify_and_handle()
if(detected_dict["unkown"]>0) :
ts.unkown_handler()
# print(detected_dict)
if(len(detected_dict["approved"])>0) :
for name in detected_dict["approved"] :
ts.send_message("Welcome home {}".format(name.title()))
if(len(detected_dict["registered"])>0) :
for name in detected_dict["registered"] :
ts.send_message("Detected {}".format(name.title()))
except Exception:
logger.warn("Something somewhere is wrong", exc_info=True)
main()