No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-02-17 14:21:32 +05:00
Readme.md Add files via upload 2026-02-17 14:21:32 +05:00

🛡️ Project Sentinel: Real-Time AI Security System

Sentinel is a full-stack security application that transforms any video feed into an intelligent monitoring device. Unlike simple motion detectors, Sentinel uses Facial Recognition to distinguish between authorized residents ("Friend") and unauthorized personnel ("Intruder").

Crucially, this system operates in Real-Time. When an event occurs, the web dashboard updates instantly without the user needing to refresh the page.


🏗️ The Three Pillars of Sentinel

The system is divided into three distinct applications that communicate with each other:

1. The Sentry (Python + Computer Vision)

  • Role: The "Eyes" and "Brain."

  • Video Source Agnostic: This script is designed to accept input from any video source:

  • Standard Webcam: (cv2.VideoCapture(0))

  • External USB Camera: For better positioning.

  • CCTV / IP Camera: Connect to a security feed via Wi-Fi (rtsp://192.168.1.x...).

  • Phone Stream: Use an old phone as a wireless IP camera.

  • Logic:

  • Motion Detection: Uses OpenCV to detect changes between frames to save processing power.

  • Face Recognition: When motion is detected, it scans for faces.

  • IFF (Identification Friend or Foe): It compares the detected face against a folder of known_faces.

  • Match: Flags event as SAFE.

  • No Match: Flags event as INTRUDER.

  • Action: It packages the Image, Timestamp, and Status and sends it to the Server API.

2. The Hub (Node.js & Express)

  • Role: The "Traffic Controller."
  • Responsibility: It sits between the Python script and the React dashboard.
  • Database Interaction: When Python sends an alert, the Hub saves the metadata to your Database (e.g., PostgreSQL) and saves the image file to the disk/cloud.
  • Real-Time Broadcasting: This is the key feature. The Hub uses Socket.io. As soon as an alert is processed, it "broadcasts" a message to all connected web clients: "New Event Received!"

3. The Dashboard (React)

  • Role: The "Command Center."
  • Responsibility: A visual interface for the user to monitor their space from any device (phone, laptop, tablet).
  • Connection: On load, it fetches the recent history from the Database. It also opens a permanent WebSocket connection to the Hub.
  • Live Updates: When the Hub broadcasts "New Event Received!", the React dashboard instantly animates the new card to the top of the list, flashes the screen red (if Intruder), and plays a warning sound.

⚡ The Data Flow (Real-Time)

This is the exact journey of a single "Intruder Alert":

  1. 0.0s: An unknown person walks into the camera's view.
  2. 0.1s: Python detects a face in the video stream (Webcam or CCTV) and fails to match it to me.jpg.
  3. 0.5s: Python sends a POST request to http://localhost:3000/api/alert.
  4. 0.6s: Node.js receives the request, saves the intruder's photo, and logs the event to the Database.
  5. 0.7s: Node.js fires a Socket.io event named new_alert.
  6. 0.8s: Your React Dashboard triggers a useEffect hook to display the new photo with a Red Border and plays siren.mp3.

💾 The Data Structure

To make this work, your Database (e.g., PostgreSQL) will need a table structure similar to this:

Column Type Description
id UUID Unique ID for the event.
camera_id String Which camera saw it? (e.g., "Hallway_Cam_1")
timestamp DateTime When did it happen?
status String 'SAFE' or 'INTRUDER'
image_path String Link to the saved photo (e.g., /images/alert_55.jpg)

🌟 Bonus Challenges for a Pro

  • The "Shame" Sound: If an intruder is detected, make the Python script play a loud sound file like "GET OUT OF MY ROOM!"