Inspiration
Small and mid-sized manufacturing lines often struggle to adopt automated visual inspection because commercial machine-vision suites require expensive GPU clusters, proprietary cameras, or opaque cloud pipelines. At the same time, deploying raw AI models directly onto a factory floor without deterministic guardrails or human-in-the-loop review creates operational risk.
We built LineGuard CV to bridge that gap: a local-first, CPU-first, evidence-backed industrial computer vision platform foundation that runs on commodity hardware, keeps operational footage on-premise, and enforces strict safety boundaries between software alerts and physical machinery.
What it does
LineGuard CV provides an end-to-end workspace for station-level quality screening and assembly monitoring:
- Multi-Source Vision Screening: Processes both uploaded inspection clips (via a persistent background job queue) and live RTSP/RTSPS/webcam feeds via a dedicated sampling worker with automatic reconnects and health tracking.
- Deterministic CPU Heuristics: Includes built-in OpenCV rules for HSV color presence (checking component presence within normalized ROI zones), motion-stall detection (flagging unexpected station inactivity), and surface-defect candidate screening (using background suppression, morphology, and connected components to spot scratch/crack-like anomalies).
- Optional CPU YOLO Adapter: Supports user-supplied Ultralytics YOLO weights pinned to
device="cpu"for custom object detection and class-absence rules—complete with dataset validation, a CPU training script, and a precision/recall/F1 + latency benchmarking utility. - Evidence-First Operator Review: Every flagged anomaly generates an evidence-backed event tied to a specific site, station, and rule. Operators can review events, manage lifecycles, and export CSV reports from a clean Charcoal + Copper Next.js dashboard.
- Safe Modbus TCP PLC Boundary: Includes an optional Modbus TCP adapter that defaults to simulation and output-disabled mode. Detections never automatically stop machinery; hardware writes require explicit commissioning and manual operator confirmation on a dedicated request bit.
How we built it
- Backend & Workers: Built with Python 3.11+ and FastAPI (
/api/v1), backed by SQLAlchemy and Alembic migrations (supporting SQLite for local single-worker trials and PostgreSQL for multi-worker Docker Compose deployments). Video and live-camera processing are decoupled from HTTP requests using dedicated background workers (workerandcamera-worker). - Vision & ML Pipeline: Powered by OpenCV for deterministic heuristics and bounded frame sampling (
DEFAULT_FRAME_STRIDE,MAX_SAMPLED_FRAMES), alongside an optional Ultralytics + PyTorch CPU runtime and Modbus TCP integration. - Security & Multi-Tenancy: Implements organization-scoped authorization,
scryptpassword hashing, signedHttpOnlysession cookies, double-submit CSRF protection, login rate limiting, and full audit logging. - Frontend: Built with Next.js (App Router) and TypeScript, featuring workspaces for video analysis, live events, station/rule configuration, camera/PLC integrations, and reporting.
- Infrastructure & Testing: Fully containerized via Docker Compose (with a hardened production overlay) and verified with Pytest coverage across API, authentication, tenant isolation, and analysis workflows.
Challenges we ran into
- Bounding CPU Load Without Dropping Critical Frames: High-resolution manufacturing feeds can easily overwhelm a CPU if decoded naively. We engineered configurable frame-stride sampling, upper frame bounds per job, and live event deduplication windows (
LIVE_EVENT_DEDUPE_SECONDS) so stations stay responsive on standard hardware. - Designing Honest Industrial Safety Boundaries: In manufacturing, a false positive or an unvalidated model should never trigger an uncontrolled line stop or claim factory safety certification. We designed the PLC adapter around a strict "simulation and output-disabled by default" architecture, ensuring that even when commissioned, the platform only issues a manually confirmed, momentary stop-request bit rather than acting as a safety PLC.
- Reducing False Positives on Surface Defects: Lighting shifts and reflections easily trip basic thresholding. Combining background suppression with morphological filtering and connected-component screening allowed us to isolate scratch/crack-like candidates while keeping the pipeline transparent and tunable per station ROI.
Accomplishments that we're proud of
- Delivering a complete, production-minded architecture—including tenant isolation, CSRF/session security, audit logs, background workers, and Docker Compose orchestration—rather than a brittle single-script demo.
- Building an honest, engineering-first validation framework that pairs deterministic OpenCV rules with a custom YOLO CPU training and benchmarking suite (measuring box precision, recall, F1, and CPU latency).
- Creating a cohesive Charcoal + Copper operator interface that unifies offline video batch jobs, live RTSP camera health, rule configuration, and PLC connection testing in one place.
What we learned
- Deterministic computer vision (HSV ROI ratios, morphological filtering, frame differencing) solves a surprising share of baseline station monitoring problems at a fraction of the compute cost of deep learning—especially when paired with an optional YOLO adapter for complex parts.
- Clear scope and safety documentation are just as important as code in industrial software. Explicitly separating software screening from certified physical protection builds far more trust with plant engineers.
What's next for LineGuard CV
- Curating blind holdout datasets on target factory lighting/SKU setups to publish hardware-specific CPU latency and accuracy benchmarks.
- Expanding multi-camera load testing and distributed worker orchestration for larger plant deployments.
- Adding richer ROI drawing tools directly inside the Next.js station configuration UI.
Built With
- docker
- fastapi
- modbus
- nextjs
- opencv
- postgresql
- pytest
- python
- pytorch
- rtsp
- sqlalchemy
- typescript
- ultralytics
- yolo

Log in or sign up for Devpost to join the conversation.