Skip to content

Thanushnaidu/Stranger-Detection-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stranger Detection System - Video Processing Pipeline

This is a computer vision project for face analysis from surveillance videos. Currently includes STEP-1 through STEP-4.

STEP-1: Video Dataset Preparation and Access

This step focuses on video dataset preparation and access.

Usage for STEP-1

  1. Place your video files (AVI/MP4) in the dataset/videos/ directory.
  2. Run the script:
    python src/video_dataset_prep.py
    

The script will scan all video files, validate them, and display their properties (filename, FPS, total frames, duration).

Output for STEP-1

For each valid video:

  • Video filename
  • FPS
  • Total frames
  • Duration in seconds

For invalid videos, an error message is logged, and processing continues.

STEP-2: Frame-by-frame Video Traversal and Timestamp Mapping

This step performs frame-by-frame traversal of videos and calculates timestamps for each frame.

Usage for STEP-2

  1. Ensure videos are in dataset/videos/ directory.
  2. Run the script:
    python src/video_frame_traversal.py
    

The script will process each video frame-by-frame, calculate timestamps, and log progress every 100 frames.

Output for STEP-2

For each video:

  • Processing start message with FPS
  • Progress logs: Frame number, timestamp in HH:MM:SS and seconds
  • Completion message with total frames processed

STEP-3: Face Detection from Video Frames

This step performs face detection on each frame using Haar Cascade.

Prerequisites for STEP-3

  1. Install MTCNN:
    pip install mtcnn
    
    Or ensure it's in requirements.txt.

Usage for STEP-3

  1. Ensure videos are in dataset/videos/ and Haar Cascade XML is in models/.
  2. Run the script:
    python src/face_detection.py
    

The script will process each video frame-by-frame, detect faces using MTCNN, and save cropped faces.

Output for STEP-3

When faces are detected and saved:

  • Video name, frame number, timestamp, number of faces saved

Faces are saved in dataset/faces/<video_name>/face_f<frame>_t<timestamp>_p<index>.jpg

STEP-4: Face Cropping and Intelligent Saving

This step crops detected faces, resizes them, and saves them intelligently to avoid duplicates.

Usage for STEP-4

  1. Ensure videos are in dataset/videos/ and Haar Cascade XML is in models/.
  2. Run the script:
    python src/face_cropping.py
    

The script will process each video, detect faces, crop and resize them (160x160), and save all faces at fixed intervals (every 30 frames).

Output for STEP-4

When faces are saved (every 30 frames):

  • Video name, frame number, timestamp, number of faces saved

Faces are saved in dataset/faces/<video_name>/face_f<frame>_t<timestamp>_p<index>.jpg

Project Structure

  • dataset/videos/: Place your video files here (AVI and MP4 formats)
  • dataset/faces/: Cropped face images saved here, organized by video
  • src/: Source code
  • models/: DNN model files (prototxt, caffemodel) and other models
  • logs/: Reserved for future logging (not used in current steps)

Requirements

  • Python 3.11+
  • OpenCV

Installation

  1. Clone or download the project.
  2. Install dependencies:
    pip install -r requirements.txt
    

Troubleshooting

  • Ensure videos are in dataset/videos/ directory.
  • Supported formats: AVI, MP4.
  • If OpenCV fails to read a video, check if the file is corrupted or in an unsupported codec.

About

Stranger Detection System is an AI-powered application that analyzes video to identify known and unknown individuals. It uses MTCNN, OpenCV, and DeepFace (ArcFace) for face detection and embeddings, DBSCAN for clustering, and cosine similarity for classification, with a React and FastAPI-based interface for real-time processing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors