AndrewLam489's picture
Update app.py
92e81f9 verified
raw
history blame
745 Bytes
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")
# 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.SENDRECV, # Use WebRtcMode enum instead of string
)