test / app.py
verma007's picture
Upload app.py
24fe04a verified
raw
history blame contribute delete
744 Bytes
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()