Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -84,29 +84,22 @@ if upload_option == "Image Upload":
|
|
84 |
|
85 |
elif upload_option == "Webcam":
|
86 |
st.sidebar.write("Webcam Capture")
|
87 |
-
|
88 |
-
stop_webcam = st.sidebar.button('Stop Webcam')
|
89 |
FRAME_WINDOW = st.image([])
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
st.
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
break
|
104 |
-
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
105 |
-
processed_frame = video_frame_callback(frame)
|
106 |
-
FRAME_WINDOW.image(processed_frame)
|
107 |
-
if stop_webcam:
|
108 |
-
st.session_state['run'] = False
|
109 |
-
camera.release()
|
110 |
-
break
|
111 |
else:
|
112 |
st.write("Please select an option to start.")
|
|
|
|
|
|
84 |
|
85 |
elif upload_option == "Webcam":
|
86 |
st.sidebar.write("Webcam Capture")
|
87 |
+
run = st.checkbox('Run Webcam')
|
|
|
88 |
FRAME_WINDOW = st.image([])
|
89 |
|
90 |
+
camera = cv2.VideoCapture(0)
|
91 |
+
|
92 |
+
while run:
|
93 |
+
success, frame = camera.read()
|
94 |
+
if not success:
|
95 |
+
st.error("Unable to read from webcam. Please check your camera settings.")
|
96 |
+
break
|
97 |
+
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
98 |
+
processed_frame = video_frame_callback(frame)
|
99 |
+
FRAME_WINDOW.image(processed_frame)
|
100 |
+
|
101 |
+
camera.release()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
else:
|
103 |
st.write("Please select an option to start.")
|
104 |
+
|
105 |
+
|