Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -121,6 +121,7 @@ def process_video_and_save(uploaded_file):
|
|
121 |
def live_video_feed():
|
122 |
stframe = st.empty() # Placeholder for the video stream in Streamlit
|
123 |
video = cv2.VideoCapture(0) # Capture live video from the webcam
|
|
|
124 |
|
125 |
while True:
|
126 |
ret, frame = video.read()
|
@@ -139,11 +140,16 @@ def live_video_feed():
|
|
139 |
# Display the processed frame in the Streamlit app
|
140 |
stframe.image(processed_frame_rgb, channels="RGB", use_column_width=True)
|
141 |
|
|
|
|
|
|
|
|
|
142 |
# Stop the live feed when the user clicks the "Stop" button
|
143 |
if st.button("Stop"):
|
144 |
break
|
145 |
|
146 |
video.release()
|
|
|
147 |
|
148 |
|
149 |
def main():
|
@@ -185,4 +191,4 @@ def main():
|
|
185 |
|
186 |
|
187 |
if __name__ == "__main__":
|
188 |
-
main()
|
|
|
121 |
def live_video_feed():
|
122 |
stframe = st.empty() # Placeholder for the video stream in Streamlit
|
123 |
video = cv2.VideoCapture(0) # Capture live video from the webcam
|
124 |
+
start_time = time.time() # Start timer for live feed
|
125 |
|
126 |
while True:
|
127 |
ret, frame = video.read()
|
|
|
140 |
# Display the processed frame in the Streamlit app
|
141 |
stframe.image(processed_frame_rgb, channels="RGB", use_column_width=True)
|
142 |
|
143 |
+
# Display the timer (elapsed time)
|
144 |
+
elapsed_time = time.time() - start_time
|
145 |
+
st.write(f"Elapsed Time: {elapsed_time:.2f} seconds")
|
146 |
+
|
147 |
# Stop the live feed when the user clicks the "Stop" button
|
148 |
if st.button("Stop"):
|
149 |
break
|
150 |
|
151 |
video.release()
|
152 |
+
st.stop() # Stop the app from reloading after stopping the live feed
|
153 |
|
154 |
|
155 |
def main():
|
|
|
191 |
|
192 |
|
193 |
if __name__ == "__main__":
|
194 |
+
main()
|