Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,7 @@ import matplotlib.pyplot as plt
|
|
14 |
|
15 |
import io
|
16 |
import streamlit as st
|
17 |
-
|
18 |
|
19 |
|
20 |
|
@@ -82,19 +82,22 @@ def cam():
|
|
82 |
return render_template('attendance.html')
|
83 |
|
84 |
def main():
|
85 |
-
|
86 |
-
|
87 |
-
bytes_data = None
|
88 |
-
if img_file_buffer is not None:
|
89 |
-
test_image = Image.open(img_file_buffer)
|
90 |
-
st.image(test_image, use_column_width=True)
|
91 |
-
st.write(type(test_image))
|
92 |
-
image = np.asarray(test_image)
|
93 |
-
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
94 |
-
st.image(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
|
95 |
-
if bytes_data is None:
|
96 |
-
st.stop()
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
return render_template('attendance.html')
|
99 |
|
100 |
|
|
|
14 |
|
15 |
import io
|
16 |
import streamlit as st
|
17 |
+
import streamlit_webrtc as webrtc
|
18 |
|
19 |
|
20 |
|
|
|
82 |
return render_template('attendance.html')
|
83 |
|
84 |
def main():
|
85 |
+
webrtc_ctx = webrtc.client(ctx=st)
|
86 |
+
webrtc_ctx.create_stream()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
+
while True:
|
89 |
+
if webrtc_ctx.video_receiver:
|
90 |
+
frame = webrtc_ctx.video_receiver.get_frame()
|
91 |
+
if frame is not None:
|
92 |
+
image = frame.to_ndarray(format="bgr24")
|
93 |
+
# Process the image with OpenCV as needed
|
94 |
+
|
95 |
+
# Display the processed image
|
96 |
+
st.image(image, channels="BGR")
|
97 |
+
else:
|
98 |
+
st.write("Waiting for video...")
|
99 |
+
st.sleep(0.1)
|
100 |
+
|
101 |
return render_template('attendance.html')
|
102 |
|
103 |
|