How pguillenortiz/https---github.com-pguillenortiz-yolo-flask-streamer works
Project type and purpose
• This is a full-stack real-time video-streaming application that integrates a YOLO object detection model with a Flask web server.
• It captures frames from a camera, runs YOLO inference, streams annotated frames to a browser, and sends control signals to industrial PLCs over OPC-UA.
File structure
• Top-level:
• run.py / wsgi.py — application entry points
• config.py + instance/config.py — configuration management
• models/ — YOLO model artifacts (.pt, .onnx, TensorRT engine)
• phantom_client.py — auxiliary PLC-client script
• app/ (Flask application):
• __init__.py — Flask app factory
• routes.py — HTTP endpoints (index, video stream)
• camera.py — Video capture & OPC-UA client logic
• detector.py — YOLO inference logic
• utils.py — shared helpers
• static/ (css, js) & templates/ (index.html, video.html) — front-end
Extract insights from the README
• Tech stack: Python 3.6+, Flask, OpenCV, Ultralytics YOLO, python-opcua, NumPy, optional Docker with GPU.
• Flow: capture → detect → post-process → stream → OPC-UA signals → browser.
• Docker packaging uses an Ultralytics base image, exposes port 5000, devices for camera & GPU.
Diagramming guidance
a. Main components
• Video Source (e.g., /dev/video0)
• Camera & OPC-UA Client module (app/camera.py)
• Detector module (app/detector.py + models/)
• Flask Web Server (app/routes.py + run.py/wsgi.py)
• Front-end (templates + static/js & static/css)
• PLC / OPC-UA Server
• Auxiliary script (phantom_client.py)
• Configuration store (config.py + instance/config.py)
b. Relationships & Interactions
1. Video Source → Camera module (frame fetch)
2. Camera → Detector (frame pass)
3. Detector → Camera (annotated frame return)
4. Camera/Detector → OPC-UA client → PLC (write node values)
5. Annotated frames → Flask streaming endpoint → Browser (video.html via JS)
6. Browser requests index.html → Flask → templates + static assets
7. run.py/wsgi.py wraps the Flask app and optionally Docker/Gunicorn
c. Architectural patterns / design principles
• Modular separation: capture, detection, web routes, utilities
• Streaming architecture: server-push MJPEG or multipart/x-mixin frames
• Dependency injection via app factory and config layers (instance/config.py)
• External service integration (PLC via OPC-UA)
d. Key technologies / frameworks
• Flask (routes, app factory)
• OpenCV (video capture)
• Ultralytics YOLO (torch, ONNX, TensorRT)
• python-opcua (PLC communication)
• Docker + GPU passthrough
Detailed checklist
• [ ] All sub-modules (camera.py, detector.py, routes.py, utils.py) shown
• [ ] Model storage (models/) indicated
• [ ] Config layers (config.py vs instance/config.py) captured
• [ ] Auxiliary phantom_client.py process (if relevant)
• [ ] Docker boundary with device mappings (if used)
• [ ] External system interactions: camera hardware, PLC server, browser client