-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathface.py
More file actions
54 lines (39 loc) · 1.09 KB
/
Copy pathface.py
File metadata and controls
54 lines (39 loc) · 1.09 KB
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 face_recognition
import cv2
cam = cv2.VideoCapture(0)
cv2.namedWindow("test")
img_counter = 0
while True:
ret, frame = cam.read()
if not ret:
print("failed to grab frame")
break
cv2.imshow("test", frame)
k = cv2.waitKey(1)
if k%256 == 27:
# ESC pressed
print("Escape hit, closing...")
break
elif k%256 == 32:
# SPACE pressed
img_name = "opencv_frame_{}.jpg".format(img_counter)
cv2.imwrite(img_name, frame)
print("{} written!".format(img_name))
img_counter += 1
cam.release()
cv2.destroyAllWindows()
a1 = face_recognition.load_image_file('a1.jpg')
a1_encoding = face_recognition.face_encodings(a1)[0]
a6 = face_recognition.load_image_file('./opencv_frame_0.png')
#face_locations = face_recognition.face_locations(a6)
a6_encoding = face_recognition.face_encodings(a6)[0]
# Compare faces
result1 = face_recognition.compare_faces([a1_encoding], a6_encoding)
v=0
print("\n\n\n\n")
for i in result1:
if i:
print('This is you')
v=v+1
if v==0:
print('This is NOT you')