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.")