Spaces:
Sleeping
Sleeping
File size: 1,042 Bytes
9ad57a5 3691888 9ad57a5 2085218 9ad57a5 2085218 9ad57a5 2085218 b2efa3a 2085218 9ad57a5 2085218 9ad57a5 2628138 9ad57a5 2085218 2628138 2085218 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import streamlit as st
from streamlit_webrtc import webrtc_streamer, WebRtcMode
import av
st.title("Webcam Display Streamlit App")
# Define the callback for transforming frames (without applying any filters)
def transform(frame: av.VideoFrame):
img = frame.to_ndarray(format="bgr24") # Convert to NumPy array (BGR format)
# Simply return the image without applying any filters
return av.VideoFrame.from_ndarray(img, format="bgr24")
# Streamlit buttons (optional, to stop the stream or interact further)
stop_button_pressed = st.button("Stop")
# Display the video stream
webrtc_streamer(
key="streamer",
video_frame_callback=transform, # The transform function is only used to process frames
sendback_audio=False, # We don't need audio in this case
mode=WebRtcMode.RECVONLY, # We are only receiving the video stream (not sending any video back)
)
# If you want a "Stop" button that halts the webcam stream, you can handle this through Streamlit
if stop_button_pressed:
st.write("Stream stopped.")
|