A full-stack CCTV surveillance application that supports real-time webcam feeds, detection (face, object, license plate, violence, etc.), image/video uploads, customer plans, wanted-face/plate alerts, history tracking, and admin/customer user roles.
- Features
- Architecture
- Tech Stack
- Setup & Installation
- Usage
- Database Schema
- Plans & Permissions
- Detection Types Supported
- Frontend User Interfaces
- Contribution Guidelines
- Code of Conduct
- License
- Contact
- User roles: Admin and Customer
- Admin: add/view customers, manage accounts, view statistics; cannot access camera feeds or private detection content.
- Customer: access real-time camera/webcam feeds, upload image/video for detection, view detection history, change password, manage profile.
- Plan-based limits (e.g. Basic, Standard, Premium) → controls how many cameras, features accessible, etc.
- Real-time webcam feed using WebRTC / similar technology.
- Detection on images/videos/uploads + in real time: faces, objects, persons, pets, accidents, violence, gun detection, sound alerts (gunshots, screams), license plate detection, helmet detection, vehicle color recognition, speed detection, no-parking zone monitoring, thermal imaging (if supported).
- Wanted face / wanted license plate: upload wanted items, preview, and match.
- Annotated outputs + matching text/messages.
- Detection history: searchable, filterable, with stored data (images, dates, types, etc.).
A high level view of how components interact:
\[ Frontend (Web) ] <--> \[ Backend API (Flask / Streamlit) ] <---> \[ Detection Models / Microservices ]
\| |  
\| | -> \[ Storage (images/videos) ]
\| |
\| -> \[ Authentication & Authorization ]
|
-> WebRTC / streaming for real-time feed
- Authentication & Authorization handled via backend, role-based access.
- MongoDB (or similar NoSQL DB) for user data, detection history, wanted items, etc.
- Separate storage for:
- Admin/customer accounts
- Detection history + metadata + media files (images/videos)
- Models for detection either bundled or via separate microservices / modules.
| Component | Technology / Framework |
|---|---|
| Backend framework | Fast API (or Streamlit for some dashboards) |
| Database | MongoDB |
| Real-time feed | WebRTC or similar streaming mechanism |
| Detection / ML Models | DeepFace, OpenCV, pretrained models for object detection, custom sound event detection etc. |
| Frontend | HTML / CSS / JavaScript (lightweight), templates or React/Vue if extended |
| Storage | Local filesystem or cloud storage (S3 or equivalent) for media outputs |
| Authentication | JWT or session tokens, password hashing etc. |
- Python 3.8+
- pip / virtualenv
- MongoDB instance running (local or remote)
- (Optional) GPU / CUDA if using heavy detection models
- (Optional) Dependencies for sound detection, webcam, etc.
git clone https://github.com/safe-cam/cctv-surveillance.git
cd cctv-surveillanceCreate a virtual environment, activate it:
python3 -m venv venv
# On Windows: venv\Scripts\activateInstall Python dependencies:
pip install -r requirements.txtCreate a configuration file (e.g. .env or config file) with the following (example) environment variables:
# Database
MONGO_URI=mongodb://localhost:27017/cctv_surveillance
# Detection models paths
MODEL_FACE_PATH=path/to/face_model
MODEL_VEHICLE_PATH=path/to/vehicle_model
# Storage paths
MEDIA_UPLOAD_FOLDER=/path/to/uploads
MEDIA_OUTPUT_FOLDER=/path/to/annotated_outputs
First, ensure MongoDB is running. Then:
# fast api
uvicorn main:app --reload
# OR, use CLI
fastapi dev main.py
# For serving real-time video / WebRTC, ensure correct webcams / RTSP streams are configured(Optional) For development mode with hot reload, debugging:
export FLASK_DEBUG=1- Register / Login as admin or customer.
- Admin can add customers, assign plans.
- Customer can connect camera(s), or upload images/videos for detection.
- Use the UI to view real-time streams (if applicable), and see detection annotations.
- View detection history, filter by date, type, etc.
- Manage “wanted” faces / plates: upload images, description; system tries matching if detection triggers.
Here’s a suggested schema if using MongoDB:
-
users{ _id: ObjectId, username: string, email: string, password_hash: string, role: "admin" | "customer", profile_photo_url: string, plan: "basic" | "standard" | "premium", camera_limit: number, created_at: datetime, updated_at: datetime } -
cameras{ _id: ObjectId, user_id: ObjectId, camera_name: string, stream_url / device_info: string, is_active: boolean, created_at: datetime } -
detection_history{ _id: ObjectId, user_id: ObjectId, camera_id: ObjectId (optional, for real-time feed), upload_type: "image" | "video" | "webcam", detection_type: string, // e.g. “face”, “accident”, etc. result_annotation_path: string, // where the output image/video with boxes etc is stored message: string, // e.g. “Wanted face matched”, etc. timestamp: datetime, raw_input_path: string, // original file or stream snapshot if needed } -
wanted_faces{ _id: ObjectId, description: string, image_path: string, user_uploaded_by: ObjectId, created_at: datetime } -
wanted_plates{ _id: ObjectId, plate_number: string, image_path: string, description: string, user_uploaded_by: ObjectId, created_at: datetime } -
plans(optional, if dynamic){ _id: ObjectId, name: "basic" | "standard" | "premium", camera_limit: integer, features: [ string ], // list of detection types enabled price: number }
| Plan | Max Cameras | Upload + Detection | Real-Time Feed | Additional Detection Features |
|---|---|---|---|---|
| Basic | ~5 | ✔ | ✔ | Limited / only core features |
| Standard | ~10 | ✔ | ✔ | More detection types, faster processing |
| Premium | ~20 | ✔ | ✔ | All detection types, more resource allocation |
Access control:
- Only customers with an active plan get certain features.
- Admin cannot access user private detections.
- Users can only view their own cameras & detection history.
- Face detection / recognition / wanted-face matching
- Person / object detection
- Pet detection
- Gun detection + sound detection (gunshots, screams)
- Accident detection
- License plate detection & recognition
- Helmet detection
- Vehicle color recognition
- Speed detection
- No-parking / restricted zone monitoring
- Thermal imaging (optional / advanced)
- Login / Register pages
- Dashboard (customer): list of cameras, status, plan info
- Real-time view: stream from camera/webcam
- Upload interface: upload image or video, select detection type, submit, receive annotated output
- Detection history page: preview thumbnails, details, filtering
- Wanted items page: for uploading/viewing wanted faces/plates
- Admin dashboard: list / manage customers, assign plans, view system-wide statistics (optional)
We welcome contributions! 🤝
-
Fork the repository.
-
Create a new branch for your feature or bugfix:
git checkout -b feature/my-feature
-
Make your changes, add tests if relevant.
-
Ensure code follows existing style/format (PEP8, lint).
-
Update or add documentation (README, commenting).
-
Commit your changes with descriptive message.
-
Push your branch:
git push origin feature/my-feature
-
Open a Pull Request (PR) against the
mainbranch, describe:- What you changed
- Why the change is needed
- How to test / steps to reproduce
-
Project maintainers will review; make requested changes if any.
Please follow these community standards:
- Be respectful in comments / code reviews.
- Write clear, readable code and documentation.
- No discriminatory, harassing or offensive content.
- Adhere to licensing.
This project is licensed under the MIT License — see the LICENSE file for details.
Project maintained by Safe-Cam organization. For questions, issues, or feature requests:
- Open an Issue