From fdb956372f555ed33a287760083c587949c85f85 Mon Sep 17 00:00:00 2001 From: Vaishvik Date: Sun, 19 Jan 2020 06:47:54 -0500 Subject: [PATCH 1/2] final --- .../sercurity_module.cpython-37.pyc | Bin 8299 -> 8309 bytes securityModule/Face/templates/index.html | 56 ++++++------------ securityModule/Face/webstreaming.py | 31 ++++++---- 3 files changed, 37 insertions(+), 50 deletions(-) diff --git a/securityModule/Face/__pycache__/sercurity_module.cpython-37.pyc b/securityModule/Face/__pycache__/sercurity_module.cpython-37.pyc index 64f721304c26046dd0cd04c4be2ecd0fc8cf2a21..6a6b4e0e33083ba2da0425d96b1c6fa94b887086 100644 GIT binary patch delta 1056 zcmYk5O>7fK6vsO@UORT|By~bQjEw`SqAec|2uS!csRbfx721>pwOhez;;fw|>s>Ru z5IGz`EkaPzL;J*~J-`9fo{-Q=t#ahXg%gKL(*p-iC_VI2<=XjgREd@R)0_9+ysvrQ zoc?z@UCU>@Ca5xZ?*>6PAD7 z31s+iM;~J{{55eU#>PoYy${{npja%O396ZQFFbRZG;l3Oh;r(&KD~E~a0x z2^!5zu?iWPQ;BhvU(zp`^3Vh%t?t;C8^|uZ#hX^G6Ie2Qoq5et7nD_JVuGG!t0SMI z=r4ddpaOgeTqG?wsp_fb^bF#O1>jOBa-A4ENq_g2*%)Q}cFlaO^hSaU!8RKUzlJdxDNHqoYkj{n?Jx{AI*|WpO8PL*B8g>&z<|{7M01+xM;R)S9HU%Ta96J=+r1Oi)jU!Kn`EDp|}PJzz=7J*I6ctgWH1Bn~~vu48=(D zMSsa|G(--DgVbF($qvv=VLF3uW!!cf;xbWTZ?pl%j^Gk^B)upcWmm(kLYuLlXt}tD z)#yQSIR9P-b$MRzQ3d`{ENKWO>hxE!oRo1jY;l`nrLn;up}qwiQqZ&izsu=TS(jab zty&3qt8Hj456>X(!}WXM0k97IKzB=PshSeiK7U84-Icj9==T8#E6xC)0MX_ckiG#- zU>R_L0Ekv#4brzjRN>EbZ};33_G0_LQG^t=Gz=*PU{Ph<@A%?V9M1xG0HVIK@gEgW B3~B%X delta 1086 zcmYk5O>7fK6vvquJC2<=2?;pC*qDzfEF=vG0uc@*K=~@AknpL2;!f$ z#Mc3k5JH_Z;>4ksB3KE*t%zgQOObl8gb+d;5a-ZiJO2&P?%}65@4bCr^JZ@R<9K3c zTU%m*{`RbYoVe4J+BG!o+UC%-aD6G9;Mb;iEX5<1=QmvS_(8CY6L|(k3;W=x5)m9}|DDLA5S9!Uj}1IU4QL zS-EQ3w1dfD>w>Gu^cd;w1cEt5gVn>5A%6t4H0t*;X~z{d_T^gf}5)O(Qa2 zVO70c{C7WZKIWWr+!@DcB^NP=;hGAAS#C-A(sexAtllmeV5d|no!wZ~4!oVJQ$^1f zmQ}2fuuZDr-_0;39epm&-#Uf87lJeC11xQ7t4_|~34Hhm5?8qOo<{ceFQ` zH+YLLb<4i6YdmJ_7v?&21+G_tYru8jhPs!VjiV&J_p@rz@}Y@vch|s(urvy62g2n# z0_iAl68H%y0~Qdj!+A(`Agu7N`g!@p2zF%t4P_yPE#ZMs9KbF&B3|92JviCamera 1 Logs -
-
-
Camera 2 Logs
-
-
-
    - -
-
-
@@ -190,9 +174,7 @@
Camera 2 Logs
get_camera1_Logs(); - get_camera2_Logs(); - function get_camera1_Logs(){ $.ajax({ type: 'POST', @@ -201,7 +183,7 @@
Camera 2 Logs
success: function(data){ let proxy = JSON.parse(data); let camera1 = $('#camera1').data('value'); - if (camera1 == "on"){ + if (camera1 == "on" && proxy['name'] != 'undefined'){ $('#result1').append( "
  • "+ proxy['time']+ ": "+ proxy['name'] +"
  • " ); } }, @@ -212,24 +194,24 @@
    Camera 2 Logs
    }); } - function get_camera2_Logs(){ - $.ajax({ - type: 'POST', - url: "/_view_logii", - dataType: "text", - success: function(data){ - let proxy = JSON.parse(data); - let camera2 = $('#camera2').data('value'); - if (camera2 == "on"){ - $('#result2').append( "
  • "+proxy['time']+ ": "+ proxy['name'] +"
  • " ); - } - }, - complete: function() { - // Schedule the next request when the current one's complete - setTimeout(get_camera2_Logs, 5000); - } - }); - } + // function get_camera2_Logs(){ + // $.ajax({ + // type: 'POST', + // url: "/_view_logii", + // dataType: "text", + // success: function(data){ + // let proxy = JSON.parse(data); + // let camera2 = $('#camera2').data('value'); + // if (camera2 == "on"){ + // $('#result2').append( "
  • "+proxy['time']+ ": "+ proxy['name'] +"
  • " ); + // } + // }, + // complete: function() { + // // Schedule the next request when the current one's complete + // setTimeout(get_camera2_Logs, 5000); + // } + // }); + // } // function get_camera3_Logs(){ // $.ajax({ diff --git a/securityModule/Face/webstreaming.py b/securityModule/Face/webstreaming.py index e9b18f9..79579c3 100644 --- a/securityModule/Face/webstreaming.py +++ b/securityModule/Face/webstreaming.py @@ -1,6 +1,6 @@ # USAGE # python webstreaming.py --ip 0.0.0.0 --port 8000 - +from twilio.rest import Client # import the necessary packages from sercurity_module import Sercurity # from imutils.video import VideoStream @@ -20,7 +20,7 @@ from firebase_admin import credentials, firestore import json -cred = credentials.Certificate('/home/haotian/uoftHacks2020/supervisor-f2f29-firebase-adminsdk-l2twy-ae836f2735.json') +cred = credentials.Certificate('/Users/vaishvik/Desktop/uoftHacks2020/supervisor-f2f29-firebase-adminsdk-l2twy-ae836f2735.json') default_app = firebase_admin.initialize_app(cred) @@ -44,22 +44,25 @@ doc_ref.set(Gfeatures) +def send_msg(number, data): + account_sid = os.environ["TWILIO_ACCOUNT_SID"] + auth_token = os.environ["TWILIO_AUTH_TOKEN"] + client = Client(account_sid, auth_token) + # This my person phone number + client.messages.create(to=number, from_="12563803381", body=data) -def send_log(detected1, detected2): +def send_log(detected1): t = time.localtime() current_time = time.strftime("%H:%M:%S", t) - if (detected1 != None): - doc_ref = db.collection(u'Camera').document(u'camera1') - doc_ref.update({ "Log":{"time": current_time, "name":detected1}}) - if (detected2 != None): - doc_ref = db.collection(u'Camera').document(u'camera2') - doc_ref.update({ "Log":{"time": current_time, "name":detected2}}) + doc_ref = db.collection(u'Camera').document(u'camera1') + doc_ref.update({ "Log":{"time": current_time, "name":detected1}}) + # Use Case of the function -send_log(None, "Tien") -send_log("Vash", "goku") -send_log("Vash", None) +# send_log(None, "Tien") +# send_log("Vash", "goku") +# send_log("Vash", None) # initialize the output frame and a lock used to ensure thread-safe # exchanges of the output frames (useful for multiple browsers/tabs @@ -138,7 +141,9 @@ def detect_motion(frameCount, datasets_path, vs): # print(dangers) if dangers != None: print(dangers[0].tostring(), "detected!!!!!!!, Confidence score =", danger_scores[0]) - send_log(dangers[0].tostring(), None) + send_log(dangers[0].tostring()) + send_msg(6473348273, dangers[0].tostring()) + mo, frame_marked = sr.detect_and_show(new_frame, total, frameCount) if mo: From e149e01ce5c8263f9c142bc5e9768b463ad3c884 Mon Sep 17 00:00:00 2001 From: Vaishvik Date: Sun, 19 Jan 2020 08:35:51 -0500 Subject: [PATCH 2/2] done --- securityModule/Face/webstreaming.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/securityModule/Face/webstreaming.py b/securityModule/Face/webstreaming.py index 79579c3..11e9ee7 100644 --- a/securityModule/Face/webstreaming.py +++ b/securityModule/Face/webstreaming.py @@ -60,9 +60,9 @@ def send_log(detected1): # Use Case of the function -# send_log(None, "Tien") -# send_log("Vash", "goku") -# send_log("Vash", None) +send_log("Tien") +send_log("goku") +send_log("Disco") # initialize the output frame and a lock used to ensure thread-safe # exchanges of the output frames (useful for multiple browsers/tabs