Update app.py
Browse files
app.py
CHANGED
|
@@ -132,29 +132,31 @@ def main():
|
|
| 132 |
app = FaceAnalysis(name='buffalo_l')
|
| 133 |
app.prepare(ctx_id=0, det_size=(640, 640))
|
| 134 |
|
| 135 |
-
#
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
#
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
| 158 |
|
| 159 |
|
| 160 |
|
|
|
|
| 132 |
app = FaceAnalysis(name='buffalo_l')
|
| 133 |
app.prepare(ctx_id=0, det_size=(640, 640))
|
| 134 |
|
| 135 |
+
# Display a button to start webcam
|
| 136 |
+
if st.button("Start Webcam"):
|
| 137 |
+
# Start capturing video from webcam
|
| 138 |
+
cap = cv2.VideoCapture(0)
|
| 139 |
+
|
| 140 |
+
# Process each frame in real-time
|
| 141 |
+
while True:
|
| 142 |
+
# Capture frame-by-frame
|
| 143 |
+
ret, frame = cap.read()
|
| 144 |
+
if not ret:
|
| 145 |
+
break
|
| 146 |
+
|
| 147 |
+
# Perform face recognition
|
| 148 |
+
frame = recognize_faces(frame, names, embeddings, app)
|
| 149 |
+
|
| 150 |
+
# Display the resulting frame
|
| 151 |
+
st.image(frame, channels="BGR", use_column_width=True)
|
| 152 |
+
|
| 153 |
+
# Break the loop if 'q' is pressed or the user closes the Streamlit app
|
| 154 |
+
if st.button("Stop"):
|
| 155 |
+
break
|
| 156 |
+
|
| 157 |
+
# Release the capture
|
| 158 |
+
cap.release()
|
| 159 |
+
cv2.destroyAllWindows()
|
| 160 |
|
| 161 |
|
| 162 |
|