From b9cdecdf432aa4bb979bf373296579eb6311e8b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20Berk=20Ba=C5=9Fo=C4=9Flu?= Date: Fri, 26 Feb 2021 09:00:05 -0500 Subject: [PATCH] Fixed the software code. --- Facial_Recognition_Inference.py | 72 ++++++------------ __pycache__/Check_Up.cpython-36.pyc | Bin 2040 -> 2040 bytes __pycache__/DBHelper.cpython-36.pyc | Bin 7484 -> 7484 bytes ...cial_Recognition_Enrollment.cpython-36.pyc | Bin 2228 -> 2228 bytes ...acial_Recognition_Inference.cpython-36.pyc | Bin 3185 -> 2778 bytes ...al_Recognition_Registration.cpython-36.pyc | Bin 1125 -> 1125 bytes ...ognition_Thief_Registration.cpython-36.pyc | Bin 993 -> 993 bytes __pycache__/Remove_Face.cpython-36.pyc | Bin 3071 -> 3071 bytes __pycache__/Upload_Face.cpython-36.pyc | Bin 2012 -> 2012 bytes __pycache__/Upload_Thief.cpython-36.pyc | Bin 1717 -> 1717 bytes 10 files changed, 23 insertions(+), 49 deletions(-) diff --git a/Facial_Recognition_Inference.py b/Facial_Recognition_Inference.py index c0f8a5da9..faf75f8c3 100644 --- a/Facial_Recognition_Inference.py +++ b/Facial_Recognition_Inference.py @@ -17,9 +17,7 @@ def inference(): FACE_RECOGNITION_MODEL_PATH = pwd + '/Facial_models/dlib_face_recognition_resnet_model_v1.dat' SKIP_FRAMES = 1 - MAXIMUM_TIME = 10 THRESHOLD = 0.4 - DEMO_SHOW = False faceDetector = dlib.get_frontal_face_detector() shapePredictor = dlib.shape_predictor(PREDICTOR_PATH) @@ -28,7 +26,7 @@ def inference(): index = np.load(pwd + '/Facial_models/index.pkl', allow_pickle=True) faceDescriptorsEnrolled = np.load(pwd + '/Facial_models/descriptors.npy') - cam = cv2.VideoCapture(1) + cam = cv2.VideoCapture(0) count = 0 x1 = x2 = y1 = y2 = 0 @@ -38,8 +36,6 @@ def inference(): label = 'unknown' start = time.time() - label_counter = {} - while DBHelper.get_power() == "on": success, im = cam.read() @@ -78,60 +74,38 @@ def inference(): if minDistance <= THRESHOLD: label = DBHelper.get_firstname(index[argmin]) + "_" + DBHelper.get_lastname(index[argmin]) - #cond = True + cond = True else: label = 'unknown' - #cond = False - - if label in label_counter.keys(): - label_counter[label] += 1 - else: - label_counter[label] = 1 + cond = False # print("time taken = {:.3f} seconds".format(time.time() - t)) - if DEMO_SHOW: - cv2.rectangle(im, (x1, y1), (x2, y2), (0, 255, 0), 2) - font_face = cv2.FONT_HERSHEY_SIMPLEX - font_scale = 0.8 - text_color = (0, 255, 0) - printLabel = '{} {:0.4f}'.format(label, minDistance) - cv2.putText(im, printLabel, (int(x1), int(y1)), font_face, font_scale, text_color, thickness=2) - if DEMO_SHOW: - cv2.imshow('img', im) + cv2.rectangle(im, (x1, y1), (x2, y2), (0, 255, 0), 2) + font_face = cv2.FONT_HERSHEY_SIMPLEX + font_scale = 0.8 + text_color = (0, 255, 0) + printLabel = '{} {:0.4f}'.format(label, minDistance) + cv2.putText(im, printLabel, (int(x1), int(y1)), font_face, font_scale, text_color, thickness=2) + + cv2.imshow('img', im) k = cv2.waitKey(1) & 0xff if k == 27: break count += 1 - - if(count == MAXIMUM_TIME): - break - - print("The statics of 10 frames: ", label_counter) - - output_label =sorted(label_counter,key=lambda x:label_counter[x])[-1] - - print("Final results: ", output_label) - - if output_label == 'unknown': - cond = False - else: - cond = True - - if cond: - DBHelper.set_motor("on") - DBHelper.set_alarm("off") - start = time.time() - elif not cond: - DBHelper.set_motor("off") - DBHelper.set_alarm("on") - end = time.time() - if end - start >= 30: - thief = True - DBHelper.set_power("off") - + if cond: + DBHelper.set_motor("on") + DBHelper.set_alarm("off") + start = time.time() + elif not cond: + DBHelper.set_motor("off") + DBHelper.set_alarm("on") + end = time.time() + if end - start >= 30: + thief = True + DBHelper.set_power("off") DBHelper.set_alarm("off") DBHelper.set_motor("off") @@ -141,4 +115,4 @@ def inference(): if __name__ == "__main__": - inference() + inference() \ No newline at end of file diff --git a/__pycache__/Check_Up.cpython-36.pyc b/__pycache__/Check_Up.cpython-36.pyc index 3814bc3c35ce402da833b0c45b05a6813253ae9b..4ffe1183b92cc7e64bb365cd60bc52b310a925a3 100644 GIT binary patch delta 16 Xcmeyt|AU|1n3tDpMY+XB_K)lUFU$pW delta 16 Xcmeyt|AU|1n3tEUVuRL3_K)lUFN_6m diff --git a/__pycache__/DBHelper.cpython-36.pyc b/__pycache__/DBHelper.cpython-36.pyc index 350d70b8f74df8a35ac7ebb505cd853a494ee557..f5b7c0b97d5805a65e72e370e5de4788b8ccece2 100644 GIT binary patch delta 16 XcmdmEwa1Fxn3tDpMY+XBc2ijZEEWW; delta 16 XcmdmEwa1Fxn3tC;;hx?`c2ijZELH@; diff --git a/__pycache__/Facial_Recognition_Enrollment.cpython-36.pyc b/__pycache__/Facial_Recognition_Enrollment.cpython-36.pyc index d95b222b1f92f92a02bc1cd6d03a3835ab00568c..96c284198db4aecea3d93a93d9d2683406cf20b0 100644 GIT binary patch delta 16 XcmdlYxJ8iNn3tDpMY+XB_O%=UCxry9 delta 16 XcmdlYxJ8iNn3tF9%{tzV>}xpyDbxi0 diff --git a/__pycache__/Facial_Recognition_Inference.cpython-36.pyc b/__pycache__/Facial_Recognition_Inference.cpython-36.pyc index f85c67a604e77a1cc8b3d3a850f45d0a4cdf0120..a927dcb75744537ab1ca100c6e404c5f60edbe64 100644 GIT binary patch delta 1172 zcmZWnOOG2x5bkP^?Rj{{9>2!#^}g8vD_|bW zmJb8s6lue70U_}RxN*1g2e@$niz7nf2tNQ(Jzj}OOsl{Cs_LumuIl-#v8>t8yRO~( z=iuWXyhrwz-mVbB=XuC;YCih@`h1oRbFol4Uh^blPWE3^qP7YNLw`A{nB z!ea%3JGGge}$0?MU!u(J6Ijr+e*<4An? zvuaZQ$rv?R-=bz%aQF^sxB3p!SijvcokuNn;C3 z+=DK4nYU4(_(G0kQz&hB!YgFi4ri_R1=qArb#kdVlH^foB(a0lI14(mq1LgcHn6KU zu^w(xh5B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GXw)?@xfwHl=y;}!)->0&VHUGK% z39kD4%6o4fM0%ZD3Yu8_x@8Qi?RQcQcj5^iK9fs zGA2YL8cq_;f1#8HGlD2^O%^0v#1a%h2w m7am5vK7K{q5WJ`HggZUjZyRfT7B>I8&qMCnGBCG$?(Zz2yq>(!qO#JxCM*XQ@IJp z&gK;NNds*8CyvcmClE-H}3F delta 192 zcmYj}F%E(-7)F62B}U?aF6sqzFfqD1Il4P^Ax-&-O(>9`65=^}3I_*|;NTS;x-)qR zJG#8#d->iF4>8>*$vAu@Px|qXY;ut~)F9JZF(q?X~V1m8wUn!ID-Zqdk}U z3^z*=O5iOpvj~=3MypO`f;UJ#&tp+hmpLFKZn3_w1VP(Tfn34e!_PF7X>;O0M1?>O; delta 18 Zcmcb^e}|vbn3tF9p07@V(MHb8>;N|Y1+)MF diff --git a/__pycache__/Upload_Thief.cpython-36.pyc b/__pycache__/Upload_Thief.cpython-36.pyc index aaa0b2345e878a1a9c658d79767351f97d2954bc..cd370a8dab0dcb7711a036246edfb1ffdb28ecb0 100644 GIT binary patch delta 16 XcmdnWyOo#Sn3tDpUAe_Z_H}FkCtU=r delta 16 XcmdnWyOo#Sn3tEU?3eOJ_H}FkD1HRu