UmairMirza commited on
Commit
91d97ae
1 Parent(s): fb46198

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -22
app.py CHANGED
@@ -37,28 +37,27 @@ def Attandance(video):
37
  index=1
38
  while True:
39
  try:
40
- ret, frame = cap.read()
41
- #faces = cv2.resize(frame, (0, 0), None, 0.25, 0.25)
42
- faces = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
43
-
44
- facesCurrentFrame = face_recognition.face_locations(faces)
45
- encodesCurrentFrame = face_recognition.face_encodings(faces, facesCurrentFrame)
46
-
47
- for encodeFace, faceLoc in zip(encodesCurrentFrame, facesCurrentFrame):
48
- matches = face_recognition.compare_faces(encodeListKnown, encodeFace)
49
- faceDis = face_recognition.face_distance(encodeListKnown, encodeFace)
50
- # print(faceDis)
51
- matchIndex = np.argmin(faceDis)
52
-
53
- if matches[matchIndex]:
54
- name = personNames[matchIndex].upper()
55
- #if names.count(name) == 0:
56
- names.append(name)
57
-
58
- cv2.waitKey(1)
59
-
60
- except:
61
- break
62
  return ''.join(name)
63
 
64
  demo=gr.Interface(fn=Attandance,
 
37
  index=1
38
  while True:
39
  try:
40
+ ret, frame = cap.read()
41
+ #faces = cv2.resize(frame, (0, 0), None, 0.25, 0.25)
42
+ faces = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
43
+
44
+ facesCurrentFrame = face_recognition.face_locations(faces)
45
+ encodesCurrentFrame = face_recognition.face_encodings(faces, facesCurrentFrame)
46
+
47
+ for encodeFace, faceLoc in zip(encodesCurrentFrame, facesCurrentFrame):
48
+ matches = face_recognition.compare_faces(encodeListKnown, encodeFace)
49
+ faceDis = face_recognition.face_distance(encodeListKnown, encodeFace)
50
+ # print(faceDis)
51
+ matchIndex = np.argmin(faceDis)
52
+
53
+ if matches[matchIndex]:
54
+ name = personNames[matchIndex].upper()
55
+ if names.count(name) == 0:
56
+ names.append(name)
57
+
58
+ cv2.waitKey(1)
59
+ except:
60
+ break
 
61
  return ''.join(name)
62
 
63
  demo=gr.Interface(fn=Attandance,