Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,9 +7,13 @@ st.title("Live Webcam Stream - Original and Flipped")
|
|
7 |
|
8 |
# Start webcam capture
|
9 |
cap = cv2.VideoCapture(0)
|
10 |
-
original_placeholder = st.empty()
|
11 |
-
flipped_placeholder = st.empty()
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
while True:
|
14 |
success, frame = cap.read()
|
15 |
if not success:
|
@@ -24,14 +28,14 @@ while True:
|
|
24 |
flipped_frame = cv2.flip(original_frame, 1)
|
25 |
flipped_img = Image.fromarray(flipped_frame)
|
26 |
|
27 |
-
# Display both original and flipped frames
|
28 |
original_placeholder.image(original_img, caption="Original Video Stream", use_column_width=True)
|
29 |
flipped_placeholder.image(flipped_img, caption="Flipped Video Stream", use_column_width=True)
|
30 |
|
31 |
-
# Stop streaming if the user presses
|
32 |
-
|
|
|
33 |
break
|
34 |
|
35 |
cap.release()
|
36 |
st.write("Stream stopped.")
|
37 |
-
|
|
|
7 |
|
8 |
# Start webcam capture
|
9 |
cap = cv2.VideoCapture(0)
|
|
|
|
|
10 |
|
11 |
+
# Create two columns to display the original and flipped video streams
|
12 |
+
col1, col2 = st.columns(2)
|
13 |
+
original_placeholder = col1.empty()
|
14 |
+
flipped_placeholder = col2.empty()
|
15 |
+
|
16 |
+
# Stream the video
|
17 |
while True:
|
18 |
success, frame = cap.read()
|
19 |
if not success:
|
|
|
28 |
flipped_frame = cv2.flip(original_frame, 1)
|
29 |
flipped_img = Image.fromarray(flipped_frame)
|
30 |
|
31 |
+
# Display both original and flipped frames in their respective columns
|
32 |
original_placeholder.image(original_img, caption="Original Video Stream", use_column_width=True)
|
33 |
flipped_placeholder.image(flipped_img, caption="Flipped Video Stream", use_column_width=True)
|
34 |
|
35 |
+
# Stop streaming if the user presses the button
|
36 |
+
stop_button = st.button("Stop Streaming")
|
37 |
+
if stop_button:
|
38 |
break
|
39 |
|
40 |
cap.release()
|
41 |
st.write("Stream stopped.")
|
|