Spaces:
Sleeping
Sleeping
import streamlit as st | |
import av | |
from streamlit_webrtc import webrtc_streamer, VideoProcessorBase | |
# Video Processor Class for Rotation | |
class RotatedVideoProcessor(VideoProcessorBase): | |
def recv(self, frame): | |
img = frame.to_ndarray(format="bgr24") # Convert frame to NumPy array | |
rotated_img = av.VideoFrame.from_ndarray(img[::-1], format="bgr24") # Rotate 180 degrees | |
return rotated_img # Return the rotated frame | |
# Streamlit UI | |
st.title("Live Webcam Streaming with Rotation") | |
# Text Input Field | |
user_input = st.text_input("Enter some text:") | |
if st.button("Confirm"): | |
st.write(f"You entered: {user_input}") | |
# Original Stream | |
st.subheader("Original Video Stream") | |
webrtc_streamer(key="original", media_stream_constraints={"video": True, "audio": False}) | |
# Rotated Stream | |
st.subheader("Rotated Video Stream") | |
webrtc_streamer(key="rotated", video_processor_factory=RotatedVideoProcessor, media_stream_constraints={"video": True, "audio": False}) | |