# πŸŽ₯ BantayCam **Integrated License Plate + Face Recognition for Philippine CCTV Infrastructure** Built with Python, FastAPI, YOLOv8, InsightFace, and PostgreSQL. --- ## Features - πŸ“‘ **RTSP Camera Management** β€” Add any IP camera by RTSP URL, name it, start/stop anytime - πŸš— **Vehicle Detection** β€” Detects car, motorcycle, jeepney, truck; identifies type + color - πŸ”’ **License Plate Recognition** β€” Reads PH plates; logs every appearance with timestamp + camera - 🏍️ **Motorcycle Person Count** β€” Counts riders on motorcycles - πŸ‘€ **Face Detection** β€” Detects and embeds every face using InsightFace ArcFace - πŸ”— **Identity Grouping** β€” Auto-groups same face across events using pgvector similarity search - πŸ—ΊοΈ **Movement Trail** β€” Query where a face or plate has been seen, on which camera, and when - 🏷️ **Labeling** β€” Register identities with names, mark vehicles as resident/blacklisted --- ## Quick Start ### Requirements - Docker + Docker Compose - (Optional) NVIDIA GPU + CUDA for real-time processing ### Run with Docker ```bash git clone http://192.168.1.159:3000/kibin/bantaycam.git cd bantaycam cp .env.example .env docker-compose up -d ``` API available at: http://localhost:8000 Swagger docs: http://localhost:8000/docs --- ## API Endpoints ### Cameras | Method | Endpoint | Description | |---|---|---| | GET | /api/v1/cameras/ | List all cameras | | POST | /api/v1/cameras/ | Register new RTSP camera | | POST | /api/v1/cameras/{id}/start | Start stream | | POST | /api/v1/cameras/{id}/stop | Stop stream | | GET | /api/v1/cameras/streams/status | Live stream status | ### Vehicles | Method | Endpoint | Description | |---|---|---| | GET | /api/v1/vehicles/identities | List all known vehicles | | GET | /api/v1/vehicles/identities/{id}/trail | Where was this vehicle seen? | | GET | /api/v1/vehicles/events | Recent vehicle detection events | | PATCH | /api/v1/vehicles/identities/{id} | Label/whitelist/blacklist a vehicle | ### Persons | Method | Endpoint | Description | |---|---|---| | GET | /api/v1/persons/identities | List all detected identities | | GET | /api/v1/persons/identities/{id}/trail | Where was this person seen? | | PATCH | /api/v1/persons/identities/{id} | Register name/watchlist | | GET | /api/v1/persons/events | Recent face detection events | --- ## Architecture ``` Camera (RTSP) β†’ StreamWorker β†’ Frame Queue β†’ DetectionPipeline β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ β”‚ VehicleDetector FaceService (YOLO + ALPR) (InsightFace) β”‚ β”‚ └───────────────────── β”‚ PostgreSQL + pgvector (Events, Identities, Embeddings) ``` --- ## Tech Stack | Component | Technology | |---|---| | Backend API | FastAPI + Python 3.11 | | Vehicle Detection | YOLOv8 (Ultralytics) | | License Plate OCR | fast-alpr (YOLOv9 + ONNX) | | Face Recognition | InsightFace ArcFace (buffalo_l) | | Database | PostgreSQL 16 + pgvector | | Containerization | Docker Compose | | Stream Ingestion | OpenCV RTSP | --- ## Development Roadmap - [ ] Phase 1: Core β€” RTSP + vehicle logging + face detection ← **YOU ARE HERE** - [ ] Phase 2: Multi-stream + SMS/push alerts + gate relay - [ ] Phase 3: Web dashboard + mobile app + LTO API integration