-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcode.py
52 lines (51 loc) · 1.15 KB
/
code.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
52
import os
import face_recognition as fr
import cv2
import time
def recognize():
c = "attrib -h -s -r /s /d facepath.txt"
os.system(c)
fi = open("facepath.txt")
fp = fi.read()
fi.close()
c1 = "attrib +h +s +r /s /d facepath.txt"
os.system(c1)
known_image = fr.load_image_file(fp)
try:
camera = cv2.VideoCapture(0)
retval,im=camera.read()
cv2.imwrite('uk.jpg',im)
del(camera)
unknown_image = fr.load_image_file("uk.jpg")
be = fr.face_encodings(known_image)[0]
ue = fr.face_encodings(unknown_image)[0]
r = fr.compare_faces([be],ue)
except:
r=[False]
#print(r[0])
os.remove("uk.jpg")
return r[0]
def main_func():
res = recognize()
if res == True:
t=os.path.basename(__file__)
nli1 = t.split(".")
#nl12 = t.split("-")
s,s2="",""
for i in range(len(nli1)-1):
s+=nli1[i]
nli2 = s.split("-")
s2=nli2[1]
s3=nli2[0]+"."+s2
cm = "attrib -h -s -r /s /d "+s3
cm1 = "attrib +h +s +r /s /d "+s3
#cm2 = "attrib +h +s +r /s /d "+"facepath.txt"
os.system(cm)
c="start "+s3
os.system(c)
os.system(cm1)
else:
c = "echo Invalid User!"
os.system(c)
time.sleep(5)
main_func()