-
Notifications
You must be signed in to change notification settings - Fork 372
Open
Description
When using FastRTC and YOLO to process video from an ESP32 camera, the following behavior occurs:
- On first launch of the application:
- A black screen is displayed instead of the video stream
- A few frames briefly appear before the stream freezes
- The stream seems to stop, leaving only a black screen
- On subsequent launches or page refresh:
Everything works correctly, video stream displays normally
fastrtc.mp4
import gradio as gr
from fastrtc import Stream
import cv2
from ultralytics import YOLO
model = YOLO("yolo12x.pt")
def process_frame(frame):
results = model.track(frame, persist=True, conf=0.4)
if results and results[0].boxes.id is not None:
return results[0].plot()
return frame
def generation():
cap = cv2.VideoCapture("http://192.168.0.100:81/stream")
while True:
success, frame = cap.read()
if not success: break
processed = process_frame(frame)
yield processed
with gr.Blocks() as app:
output = Stream(
handler=generation,
mode="receive",
modality="video"
)
if __name__ == '__main__':
app.launch()
Metadata
Metadata
Assignees
Labels
No labels