File size: 744 Bytes
24fe04a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import streamlit as st
from streamlit_webrtc import webrtc_streamer, VideoTransformerBase
import cv2
class VideoTransformer(VideoTransformerBase):
def transform(self, frame):
image = frame.to_ndarray(format="bgr24")
# Process the image with OpenCV here
# For example, a simple conversion to grayscale
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
back_to_bgr = cv2.cvtColor(gray_image, cv2.COLOR_GRAY2BGR)
return back_to_bgr
def main():
st.title("Webcam Live Feed")
st.write("This application streams your webcam video and can process it in real-time.")
webrtc_streamer(key="example", video_transformer_factory=VideoTransformer)
if __name__ == "__main__":
main()
|