AI / app.py
Raumkommander
inital deployment1
a991bc1
raw
history blame
787 Bytes
import gradio as gr
import cv2
import numpy as np
from PIL import Image
def video_stream():
"""Captures video feed from webcam and outputs the same stream to a different canvas."""
cap = cv2.VideoCapture(0)
while cap.isOpened():
ret, frame = cap.read()
if not ret:
break
yield frame
cap.release()
# Create Gradio App
with gr.Blocks() as demo:
gr.Markdown("## πŸŽ₯ Webcam Stream with Output to a Separate Canvas")
with gr.Row():
webcam_feed = gr.Video(label="Live Webcam", streaming=True)
canvas_output = gr.Image(label="Canvas - Output Stream")
start_button = gr.Button("Start Streaming")
start_button.click(fn=video_stream, inputs=[], outputs=[canvas_output])
demo.launch(share=True)