GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com β€” GitHub - dilliram-code/sentinel: An intelligent computer vision system for detecting authorized stakeholders and unauthorized individuals from CCTV streams.

BranchesTags
Open more actions menu

Latest commit

 

History

84 Commits
84 Commits

Folders and files

NameName
Last commit message
Last commit date
assets
assets
 
 
camera
camera
 
 
config
config
 
 
dashboard
dashboard
 
 
data
data
 
 
database
database
 
 
detection
detection
 
 
pipeline
pipeline
 
 
playground
playground
 
 
project/proposal
project/proposal
 
 
recognition
recognition
 
 
registration
registration
 
 
stakeholder
stakeholder
 
 
tests
tests
 
 
utils
utils
 
 
web
web
 
 
.DS_Store
.DS_Store
 
 
.env
.env
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
main.py
main.py
 
 
requirements.txt
requirements.txt
 
 
server.py
server.py
 
 
stakeholders.xlsx
stakeholders.xlsx
 
 
yolov8n.pt
yolov8n.pt
 
 

Repository files navigation

An AI-powered intelligent campus surveillance system that performs real-time person detection, stakeholder identification, and unknown person registration using YOLOv8, InsightFace, OpenCV, SQLite, and a Modern WebSocket-driven Dashboard.


πŸš€ Quick Start Instructions

  1. Check Environment:

    python main.py check
  2. Launch the Modern Web Dashboard (Recommended):

    python main.py web

    πŸ‘‰ Open http://localhost:8001 in your browser for real-time WebSocket video streaming, live visitor notifications, stakeholder management, and analytics.

  3. Or Run Surveillance in Terminal Mode:

    python main.py run --location "MBUST Lab"
  4. Bulk Register from Excel/CSV:

    python registration/bulk_register.py --sheet stakeholders.xlsx --photos-dir stakeholder

πŸ“ Project structure

campus_surveillance/
β”œβ”€β”€ main.py                        # CLI: init-db | check | register | run | list
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ config/settings.py             # every path & threshold in one place
β”œβ”€β”€ camera/webcam_stream.py        # laptop webcam (auto-detects index 0/1/2)
β”œβ”€β”€ detection/person_detector.py   # YOLOv8 person detection
β”œβ”€β”€ recognition/face_recognizer.py # InsightFace embeddings + cosine matching
β”œβ”€β”€ database/db_manager.py         # SQLite: stakeholders, visit_logs, unknown_persons
β”œβ”€β”€ pipeline/surveillance_pipeline.py  # real-time loop
β”œβ”€β”€ registration/register_stakeholder.py  # enroll via webcam or photos
β”œβ”€β”€ dashboard/app.py               # Streamlit dashboard
β”œβ”€β”€ utils/                         # logger + image helpers
β”œβ”€β”€ models/                        # (optional) fine-tuned YOLO weights
└── data/                          # created automatically at runtime
    β”œβ”€β”€ campus_surveillance.db
    β”œβ”€β”€ stakeholders/
    β”œβ”€β”€ unknown_faces/
    └── live/

❓ What goes in each data folder? (short answer: nothing β€” leave them empty)

Folder Who fills it What ends up inside
data/stakeholders/ The program, during registration One reference photo per registered person, named by UID (e.g. S001.jpg). Shown in the dashboard. Don't put files here manually.
data/unknown_faces/ The program, during surveillance Auto-cropped face images of unrecognized people, timestamped (e.g. unknown_20260704_101502_123456.jpg). Review them in the dashboard's Unknown Persons tab.
data/live/ The program, during surveillance A single latest.jpg β€” the most recent annotated frame β€” which the dashboard's Live Monitor tab displays. Overwritten continuously.
data/campus_surveillance.db The program The SQLite database (stakeholders, visit logs, unknown records).

The only folder you create is an optional photos/ folder (anywhere you like) if you prefer registering people from photo files instead of the webcam β€” e.g. photos/sita/1.jpg, 2.jpg, 3.jpg (3–5 clear, front-facing photos per person give the best accuracy).


πŸš€ Complete workflow β€” follow these steps in order

Step 0 β€” Prerequisites (one time)

  • Python 3.9 – 3.11 installed (python --version)
  • Internet connection for the first run only (models auto-download: yolov8n.pt β‰ˆ 6 MB and InsightFace buffalo_l β‰ˆ 280 MB)
  • Webcam not in use by Zoom/Teams/browser, and OS camera permission granted to your terminal (Windows: Settings β†’ Privacy β†’ Camera; macOS: System Settings β†’ Privacy & Security β†’ Camera)

Step 1 β€” Install (one time)

cd sentinel
python -m venv .venv
# Windows:
.venv\Scripts\activate
# macOS / Linux:
source .venv/bin/activate

pip install -r requirements.txt

Step 2 β€” Initialize the database (one time)

python main.py init-db

Creates data/ and all its subfolders + the SQLite database.

Step 3 β€” Self-check (one time, strongly recommended)

python main.py check

Verifies every library, downloads/loads both models, initializes the DB and tests your webcam. Fix any [FAIL] line before continuing β€” if this prints ALL CHECKS PASSED, the pipeline will run without setup errors.

Step 4 β€” Register stakeholders (once per person)

Easiest β€” straight from the webcam (captures 5 face samples automatically; look at the camera, turn your head slightly between captures):

python main.py register --uid S001 --name "Sita Sharma" --role Student --webcam

Or from photo files (file, folder, or glob; multiple photos are averaged into one robust template):

python main.py register --uid F010 --name "Dr. Ram K." --role Faculty --images ./photos/ram/

Roles: Student, Faculty, Staff, Authorized. Re-registering the same --uid safely updates that person.

Step 5 β€” Confirm registration

python main.py list

Step 6 β€” Run real-time surveillance

python main.py run
  • A preview window opens: green box = recognized stakeholder (name, role, similarity), red box = UNKNOWN (face auto-saved + DB record).
  • Visits are logged at most once per person per 60 s; the same unknown is not re-saved within 120 s (both tunable in config/settings.py).
  • Press q in the preview window (or Ctrl-C in the terminal) to stop.

Useful variants:

python main.py run --location "Home Desk"     # label stored with every log
python main.py run --source 1                 # external USB webcam
python main.py run --source test.mp4 --max-frames 300   # evaluate on a video
python main.py run --no-display               # headless (no preview window)

Step 7 β€” Open the dashboard (second terminal, same venv)

streamlit run dashboard/app.py

Tabs: Live Monitor (latest annotated frame) β€’ Visit Logs (search + CSV export) β€’ Unknown Persons (photo review queue with Mark verified) β€’ Stakeholders β€’ Reports (visits per day / location / role).

Everyday use after setup

source .venv/bin/activate        # (or .venv\Scripts\activate)
python main.py run               # terminal 1
streamlit run dashboard/app.py   # terminal 2

πŸ”§ Tuning (config/settings.py)

Setting Default Effect
FACE_MATCH_THRESHOLD 0.45 Lower β‡’ easier match (more false accepts); higher β‡’ stricter (more false UNKNOWNs). Try 0.40–0.50.
VISIT_LOG_COOLDOWN_SEC 60 Gap between repeat visit logs per person
UNKNOWN_LOG_COOLDOWN_SEC 120 De-dup window for unknown captures
FRAME_PROCESS_EVERY_N 2 Raise to 3–4 on slow laptops for smoother FPS
DISPLAY_WINDOW True Set False on headless machines

🩹 Troubleshooting

Symptom Fix
No working webcam found Close apps using the camera; grant camera permission to the terminal; try --source 1.
First run is very slow Models are downloading (one time). Watch the progress in the terminal.
Everyone shows as UNKNOWN You skipped Step 4 β€” the log even warns "gallery is EMPTY". Register people first.
You show as UNKNOWN despite being registered Improve lighting, face the camera, re-register with more/better samples, or lower FACE_MATCH_THRESHOLD slightly.
Preview window frozen / won't close Click the window, press q; or Ctrl-C in the terminal.
Dashboard shows "No live frame yet" Start python main.py run first, then click πŸ”„ Refresh.

Installation Guide

Clone Repository

git clone https://github.com/dilliram-code/sentinel.git

cd sentinel

Create Virtual Environment

macOS / Linux

python3 -m venv .venv

Activate Environment

source .venv/bin/activate

Install Dependencies

pip install -r requirements.txt

Run the Application

Main Detection System

python main.py run --location "MBUST Lab"

Streamlit Dashboard

streamlit run dashboard/app.py

Create Virtual Environment

macOS / Linux

python3 -m venv .venv

Activate Environment

source .venv/bin/activate

Install Dependencies

pip install -r requirements.txt

Run the Application

Main Detection System

python main.py

Streamlit Dashboard

streamlit run dashboard/app.py

Development Phases πŸ“ˆ

Phase 1

  • Project setup
  • Folder structure
  • Webcam testing
  • YOLO integration

Phase 2

  • SQLite database
  • Streamlit dashboard
  • Stakeholder management
  • Unknown person logging

πŸ“ˆ Future Enhancements

  • Multi-camera synchronization
  • Person tracking using ByteTrack
  • Automatic attendance management
  • Visitor management system
  • Face search from uploaded image
  • REST API backend
  • Docker deployment
  • Cloud database support
  • Role-based authentication
  • Heatmap visualization
  • Campus movement analytics
  • Mobile application

Sample Workflow

Camera
   β”‚
   β–Ό
YOLOv8
   β”‚
   β–Ό
Detect Person
   β”‚
   β–Ό
Extract Face
   β”‚
   β–Ό
InsightFace
   β”‚
   β–Ό
Embedding
   β”‚
   β–Ό
SQLite Database
   β”‚
   β–Ό
Known?──────────►YES────────►Visit Logged
   β”‚
   β–Ό
NO
   β”‚
   β–Ό
Save Unknown Face
   β”‚
   β–Ό
Dashboard Updated

Learning Objectives

This project demonstrates practical implementation of:

  • Computer Vision
  • Deep Learning
  • Face Recognition
  • Object Detection
  • Functional Programming
  • Database Design
  • Streamlit Application Development
  • Real-Time Video Processing
  • AI System Integration

Contributors

  • Dilli Ram Chaudhary (Master of Artificial Intelligence)
  • Piyush Lal Shrestha (Master of Data Science)
  • Yalamber Ingnam (Master of Data Science)

βš–οΈ Ethics note

Even in a webcam demo, face embeddings are biometric data: enroll only people who consent, and delete data/ when the demonstration is finished.

License

This project is developed for academic and research purposes.


⭐ If you find this project helpful, consider giving it a star on GitHub😊!

About

An intelligent computer vision system for detecting authorized stakeholders and unauthorized individuals from CCTV streams.

Topics

cctv-detectioncctv-surveillanceface-recognitionlivedetectionvectorembeddingsyolov8

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 β€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800Γ—600. No cookies required.