Spaces:
Runtime error
Runtime error
File size: 664 Bytes
9318948 |
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 cv2
import gradio as gr
import numpy as np
def process_frame():
cap = cv2.VideoCapture(0)
ret, frame = cap.read()
if not ret:
cap.release()
return np.zeros((512, 512, 3), dtype=np.uint8)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray, 100, 200)
edges_bgr = cv2.cvtColor(edges, cv2.COLOR_GRAY2BGR)
cap.release()
return edges_bgr
iface = gr.Interface(
fn=process_frame,
inputs=[],
outputs="image",
live=True,
title="Real-Time Edge Detection",
description="This application captures frames from the webcam and applies edge detection."
)
iface.launch() |