Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,26 @@
|
|
1 |
import streamlit as st
|
2 |
-
import
|
3 |
-
import
|
4 |
-
from streamlit_webrtc import webrtc_streamer, VideoTransformerBase
|
5 |
|
6 |
-
|
7 |
-
|
|
|
8 |
img = frame.to_ndarray(format="bgr24") # Convert frame to NumPy array
|
9 |
-
rotated_img =
|
10 |
return rotated_img # Return the rotated frame
|
11 |
|
|
|
12 |
st.title("Live Webcam Streaming with Rotation")
|
13 |
|
|
|
|
|
|
|
|
|
|
|
14 |
# Original Stream
|
15 |
st.subheader("Original Video Stream")
|
16 |
-
webrtc_streamer(key="original")
|
17 |
|
18 |
# Rotated Stream
|
19 |
st.subheader("Rotated Video Stream")
|
20 |
-
webrtc_streamer(key="rotated",
|
|
|
1 |
import streamlit as st
|
2 |
+
import av
|
3 |
+
from streamlit_webrtc import webrtc_streamer, VideoProcessorBase
|
|
|
4 |
|
5 |
+
# Video Processor Class for Rotation
|
6 |
+
class RotatedVideoProcessor(VideoProcessorBase):
|
7 |
+
def recv(self, frame):
|
8 |
img = frame.to_ndarray(format="bgr24") # Convert frame to NumPy array
|
9 |
+
rotated_img = av.VideoFrame.from_ndarray(img[::-1], format="bgr24") # Rotate 180 degrees
|
10 |
return rotated_img # Return the rotated frame
|
11 |
|
12 |
+
# Streamlit UI
|
13 |
st.title("Live Webcam Streaming with Rotation")
|
14 |
|
15 |
+
# Text Input Field
|
16 |
+
user_input = st.text_input("Enter some text:")
|
17 |
+
if st.button("Confirm"):
|
18 |
+
st.write(f"You entered: {user_input}")
|
19 |
+
|
20 |
# Original Stream
|
21 |
st.subheader("Original Video Stream")
|
22 |
+
webrtc_streamer(key="original", media_stream_constraints={"video": True, "audio": False})
|
23 |
|
24 |
# Rotated Stream
|
25 |
st.subheader("Rotated Video Stream")
|
26 |
+
webrtc_streamer(key="rotated", video_processor_factory=RotatedVideoProcessor, media_stream_constraints={"video": True, "audio": False})
|