Repository navigation
Expand file tree
/
Copy pathprogram.py
More file actions
86 lines (61 loc) · 2.19 KB
/
Copy pathprogram.py
File metadata and controls
86 lines (61 loc) · 2.19 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import serial
import time
import face_recognition
import cv2
import numpy
import os
ser = serial.Serial('COM3',9800,timeout=1)
time.sleep(2)
def main_function():
print("correct face")
text=[]
while True:
line = ser.readline().decode("utf-8")
if line =="":
pass
else:
try:
text.append(int(line))
print(text)
except:
if (line[0])== 'A':
if text == []:
pass
else:
text.pop()
print(text)
if (line[0])== 'B':
if text == []:
pass
else:
if text==[1,2,3]:
print("correct passsword")
else:
print("incorrect password")
elif (line[0]) == 'C':
video = cv2.VideoCapture(0)
face = face_recognition.load_image_file("1.jpg")
faceencoding = face_recognition.face_encodings(face)[0]
face_encodings_list = [
faceencoding]
face_encodings = []
s = True
face_coordinates=[]
while True:
_,frame = video.read()
resized_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
resized_frame_rgb = frame[:, :, ::-1]
if s:
face_coordinates = face_recognition.face_locations(resized_frame_rgb)
face_encodings = face_recognition.face_encodings(resized_frame_rgb, face_coordinates)
for faces in face_encodings:
matches = face_recognition.compare_faces(face_encodings_list, faces)
if matches[0] == True:
video.release()
cv2.destroyAllWindows()
main_function()
cv2.imshow('Face Scan', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
video.release()
cv2.destroyAllWindows()