File size: 623 Bytes
affe6d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr

# Function to display webcam image on canvas
def display_webcam_image(img):
    return img

# Gradio app interface
with gr.Blocks() as demo:
    gr.Markdown("## Webcam Capture and Display")
    # Webcam component
    webcam = gr.Image(source="webcam", label="Webcam Capture", streaming=True)
    # Canvas to display captured image
    canvas = gr.Image(label="Captured Image")

    # Button to capture image from webcam and display on canvas
    capture_button = gr.Button("Capture Image")
    capture_button.click(fn=display_webcam_image, inputs=webcam, outputs=canvas)

# Launch the app
demo.launch()