Spaces:
Sleeping
Sleeping
LovnishVerma
commited on
Commit
•
1c4942b
1
Parent(s):
610503e
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import streamlit as st
|
2 |
-
from PIL import Image
|
3 |
import face_recognition
|
4 |
import cv2
|
5 |
import numpy as np
|
@@ -58,11 +57,17 @@ Images, classnames = load_images(directory)
|
|
58 |
# Load images for face recognition
|
59 |
encodeListknown = [face_recognition.face_encodings(img)[0] for img in Images]
|
60 |
|
61 |
-
#
|
62 |
-
|
63 |
|
64 |
-
if
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
68 |
|
|
|
|
|
|
1 |
import streamlit as st
|
|
|
2 |
import face_recognition
|
3 |
import cv2
|
4 |
import numpy as np
|
|
|
57 |
# Load images for face recognition
|
58 |
encodeListknown = [face_recognition.face_encodings(img)[0] for img in Images]
|
59 |
|
60 |
+
# Camera input to take photo of user in question
|
61 |
+
capture = cv2.VideoCapture(0)
|
62 |
|
63 |
+
if capture.isOpened():
|
64 |
+
ret, frame = capture.read()
|
65 |
+
if ret:
|
66 |
+
# Recognize faces in the captured frame
|
67 |
+
image_with_recognition = recognize_faces(frame, encodeListknown, classnames)
|
68 |
+
st.image(image_with_recognition, channels="BGR", use_column_width=True)
|
69 |
+
else:
|
70 |
+
st.error("Failed to open camera.")
|
71 |
|
72 |
+
capture.release()
|
73 |
+
cv2.destroyAllWindows()
|