Spaces:
Runtime error
Runtime error
File size: 787 Bytes
0cef02f 2d6fc22 0cef02f a991bc1 2d6fc22 a991bc1 2d6fc22 f1e3f4b a991bc1 f1e3f4b a991bc1 f1e3f4b a991bc1 9332803 a991bc1 2ec7210 80a5ad2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
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)
|